コード例 #1
0
        public ActionResult DeleteWork(long id)
        {
            Work work = WorkRepository.GetWork(id);

            if (work != null)
            {
                WorkRepository.DeleteWork(work);
                return(Ok());
            }
            return(NotFound());
        }
コード例 #2
0
        public ActionResult <Work> UpdateWork(Work work, long id)
        {
            Work dbWork = WorkRepository.GetWork(id);

            if (dbWork != null)
            {
                WorkRepository.UpdateWork(work);
                return(Ok());
            }
            return(NotFound());
        }
コード例 #3
0
        public ActionResult Post(Work work)
        {
            var works = WorkRepository.GetWork();
            var newId = GetNewId(works);
            //string Date = DateTime.Now.ToString("yyyy-MM-ddTHH:mm:ss");
            DateTime Date = DateTime.Now;

            work.WorkId = newId;
            work.Date   = Date;
            works.Add(work);
            WorkRepository.StoreWork(works);

            return(Ok());
        }
コード例 #4
0
        public ActionResult <Work> Get(long id)
        {
            var works = WorkRepository.GetWork();
            var work  = works.FirstOrDefault(i => i.WorkId == id);

            if (work != null)
            {
                return(work);
            }
            else
            {
                return(NotFound());
            }
        }
コード例 #5
0
        public ActionResult Delete(long id)
        {
            var works = WorkRepository.GetWork();
            var work  = works.FirstOrDefault(x => x.WorkId == id);

            if (work != null)
            {
                works.Remove(work);
                WorkRepository.StoreWork(works);
                return(Ok());
            }
            else
            {
                return(NotFound());
            }
        }
コード例 #6
0
        public ActionResult Put(Work work)
        {
            var works   = WorkRepository.GetWork();
            var oldWork = works.FirstOrDefault(x => x.WorkId == work.WorkId);

            if (oldWork != null)
            {
                oldWork.ClientName   = work.ClientName;
                oldWork.CarType      = work.CarType;
                oldWork.LicensePlate = work.LicensePlate;
                oldWork.Problem      = work.Problem;
                oldWork.State        = work.State;
            }
            else
            {
                var newId = GetNewId(works);
                work.WorkId = newId;
                works.Add(work);
            }

            WorkRepository.StoreWork(works);

            return(Ok());
        }
コード例 #7
0
        public ActionResult NewWork(AssignShiftEmployeesViewModel viewModel)
        {
            if (ModelState.IsValid)
            {
                viewModel.Employees = _employeeRepository.GetEmployeeIdEqualsToShiftId(viewModel);
                viewModel.Shift     = _shiftRepository.GetShift();

                return(View("NewWork", viewModel));
            }

            var employee = viewModel.EmployeeId;

            if (employee.Equals(0))
            {
                return(RedirectToAction("NewWork"));
            }

            var shift = viewModel.Shift.Id;

            var exist = _workRepository.GetWork(employee, shift);

            if (exist)
            {
                return(RedirectToAction("NewWork"));
            }

            var work = new Work(viewModel.EmployeeId, viewModel.Shift.Id);

            _context.Works.Add(work);
            _context.SaveChanges();

            var shiftId = viewModel.Shift.Id;

            TempData["ID"] = shiftId;
            return(RedirectToAction("NewWork", shiftId));
        }
コード例 #8
0
        public ActionResult <IEnumerable <Work> > Get()
        {
            var works = WorkRepository.GetWork();

            return(Ok(works));
        }