Giter Club home page Giter Club logo

cs321_w2d2_studentapi's Introduction

CS321_W2D2_StudentAPI

Class project for CS321 Week 2, Day 2.

Project Instructions

  1. Fork and clone the CS321_W2D2_StudentAPI project.
  2. Open the solution in Visual Studio.
  3. Try building. It will fail. Use the errors as clues.
  4. In the Student model, use validation attributes to enforce the following:
    1. FirstName, LastName, BirthDate, Email, and Phone are required.
    2. Email must be a valid email address format.
    3. Phone must be a valid phone number format.
  5. You are given the IStudentsService interface and an incomplete implementation of it in StudentsService. The Add() method and a ValidateBirthDate() method are implemented for you. Complete the rest of the implementation.
    1. Make the Get() method return the student specified by the id parameter.
    2. Make the GetAll() method return all students.
    3. Make Update() method do the following:
      1. Find the student specified by the id parameter.
      2. Return null if the student is not found.
      3. Copy the property values of the incoming updatedStudent object to the student you found in the list in the earlier step.
      4. Return the updated student.
    4. Make the Remove() method remove the specified student.
  6. You are given a partially implemented StudentsController. Complete the implementation.
    1. Make the necessary changes to the constructor to inject the StudentService.
    2. In the Post() method, add a try/catch block around the call to _studentsService.Add(). In the catch block, add the error message to ModelState.
  7. In the Startup class, configure dependency injection for IStudentService.

If you've completed the previous steps correctly, the project should build successfully. Now let's see if you've got the logic right. Run the unit tests in the test project.

Do they all pass? If not, try looking at the failing tests to understand what they're trying to do. Try to deduce what might be wrong. Use the debugger if necessary.

Here are some manual testing ideas:

  1. Run the solution.
  2. Using Postman, try posting a variety of new Students to your API, covering the following cases:
    1. Post a new, valid student.
    2. Try posting with missing names. You should get a 400 Bad Request.
    3. Try posting a bad email address.
    4. Try posting a bad phone number.
    5. Try using a birth date prior to 2000.
    6. Try using a birth date after 2020.

cs321_w2d2_studentapi's People

Contributors

mattcam3r0n avatar hipperger avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.