コード例 #1
0
        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());
        }
コード例 #2
0
        public ActionResult Post(Work work)
        {
            var works = WorkRepository.GetWorks();

            work.Id = GetNewId(works);
            works.Add(work);
            WorkRepository.StoreWorks(works);
            return(Ok());
        }
コード例 #3
0
        public ActionResult <Work> Get(long id)
        {
            var work = WorkRepository.GetWorks().FirstOrDefault(x => x.Id == id);

            if (work != null)
            {
                return(Ok(work));
            }
            else
            {
                return(NotFound());
            }
        }
コード例 #4
0
        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());
        }
コード例 #5
0
        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());
        }
コード例 #6
0
        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());
        }
コード例 #7
0
        public ActionResult <IEnumerable <Work> > Get()
        {
            var works = WorkRepository.GetWorks();

            return(Ok(works));
        }