public ActionResult Put(Work work) { var works = WorkRepository.GetWorks(); var oldWork = works.FirstOrDefault(x => x.Id == work.Id); if (oldWork != null) { oldWork.LastName = work.LastName; oldWork.FirstName = work.FirstName; oldWork.Date = work.Date; oldWork.TypeOfCar = work.TypeOfCar; oldWork.CarLicencePlate = work.CarLicencePlate; oldWork.Issues = work.Issues; oldWork.StateOfWork = work.StateOfWork; } else { var newId = GetNewId(works); work.Id = newId; works.Add(work); } WorkRepository.StoreWorks(works); return(Ok()); }
public ActionResult Post(Work work) { var works = WorkRepository.GetWorks(); work.Id = GetNewId(works); works.Add(work); WorkRepository.StoreWorks(works); return(Ok()); }
public ActionResult <Work> Get(long id) { var work = WorkRepository.GetWorks().FirstOrDefault(x => x.Id == id); if (work != null) { return(Ok(work)); } else { return(NotFound()); } }
public ActionResult Delete(long id) { var works = WorkRepository.GetWorks(); var work = works.FirstOrDefault(x => x.Id == id); if (work != null) { works.Remove(work); WorkRepository.StoreWorks(works); return(Ok()); } return(NotFound()); }
public ActionResult Delete(long id) { var works = WorkRepository.GetWorks(); var workToRemove = works.FirstOrDefault(work => work.Id == id); if (workToRemove != null) { works.Remove(workToRemove); WorkRepository.StoreWorks(works); } else { return(NotFound()); } return(Ok()); }
public ActionResult Put(Work work) { var works = WorkRepository.GetWorks(); var foundedWork = works.FirstOrDefault(innerWork => innerWork.Id == work.Id); if (foundedWork == null) { return(NotFound()); } else { foundedWork.CarLicensePlate = work.CarLicensePlate; foundedWork.NameOfCustomer = work.NameOfCustomer; foundedWork.StateOfWork = work.StateOfWork; foundedWork.DetailOfIssues = work.DetailOfIssues; foundedWork.RecordingDate = work.RecordingDate; foundedWork.TypeOfCar = work.TypeOfCar; } WorkRepository.StoreWorks(works); return(Ok()); }
public ActionResult <IEnumerable <Work> > Get() { var works = WorkRepository.GetWorks(); return(Ok(works)); }