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 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()); }