public ActionResult <IEnumerable <MClient> > Get() { //return Ok(new[] { new MClient { FirstName = "Jhon", LastName = "Doe", CarType = "Toyota", LicensePN = "KGB-456", Description = "oil change", StartingDate = DateTime.Now } }); var mclients = MClientRepository.GetMClients(); return(Ok(mclients)); }
public void GetMclient_WithValidArgument_ClientListNotEmpty() { // Arrange var aclient = MClientRepository.GetMClients().ToList(); //Assert Assert.NotEmpty(aclient); }
public ActionResult Post([FromBody] MClient mclient) { var mclients = MClientRepository.GetMClients().ToList(); mclient.Id = GetNewId(mclients); mclients.Add(mclient); MClientRepository.StoreMClient(mclients); return(Ok()); }
public ActionResult <MClient> Get(int id) { var mclients = MClientRepository.GetMClients(); var mclient = mclients.FirstOrDefault(x => x.Id == id); if (mclient != null) { return(Ok(mclient)); } return(NotFound()); }
public void Get_WithInvalidId_ClientIsNull() { // Arrange var id = 1; // Act var clients = MClientRepository.GetMClients(); var client = clients.FirstOrDefault(x => x.Id == id); // Assert Assert.Null(client); }
public ActionResult Delete(int id) { var mclients = MClientRepository.GetMClients().ToList(); var mclientToDelete = mclients.FirstOrDefault(p => p.Id == id); if (mclientToDelete != null) { mclients.Remove(mclientToDelete); MClientRepository.StoreMClient(mclients); return(Ok()); } return(NotFound()); }
public ActionResult Put([FromBody] MClient mclient) { var mclients = MClientRepository.GetMClients().ToList(); var mclientToUpdate = mclients.FirstOrDefault(p => p.Id == mclient.Id); if (mclientToUpdate != null) { mclientToUpdate.FirstName = mclient.FirstName; mclientToUpdate.LastName = mclient.LastName; mclientToUpdate.CarType = mclient.CarType; mclientToUpdate.LicensePN = mclient.LicensePN; mclientToUpdate.Description = mclient.Description; mclientToUpdate.StartingDate = mclient.StartingDate; mclientToUpdate.Status = mclient.Status; MClientRepository.StoreMClient(mclients); return(Ok()); } return(NotFound()); }