コード例 #1
0
        public async Task <IActionResult> NewServiceOrder()
        {
            ServiceOrderVM order = new ServiceOrderVM()
            {
                CustomerList = await _db.AppUser.OrderBy(i => i.Name).Where(i => i.Customer == 1).ToListAsync(),
                ServiceOrder = new Models.ServiceOrder()
            };

            return(View(order));
        }
コード例 #2
0
        public async Task <IActionResult> EditServiceOrder(ServiceOrderVM order)
        {
            order.ServiceOrder.DateLastChange = DateTime.Now;
            if (ModelState.IsValid)
            {
                _db.ServiceOrder.Update(order.ServiceOrder);
                await _db.SaveChangesAsync();

                return(RedirectToAction(nameof(ServiceList)));
            }
            return(View(order));
        }
コード例 #3
0
        public async Task <IActionResult> NewServiceOrder(ServiceOrderVM order)
        {
            order.ServiceOrder.DateReceived   = DateTime.Now;
            order.ServiceOrder.DateLastChange = DateTime.Now;
            order.ServiceOrder.Status         = 0;

            if (ModelState.IsValid)
            {
                _db.ServiceOrder.Add(order.ServiceOrder);
                await _db.SaveChangesAsync();

                return(RedirectToAction(nameof(ServiceList)));
            }

            ServiceOrderVM orderVM = new ServiceOrderVM()
            {
                CustomerList = await _db.AppUser.OrderBy(i => i.Name).Where(i => i.Customer == 1).ToListAsync(),
                ServiceOrder = new Models.ServiceOrder()
            };

            return(View(orderVM));
        }
コード例 #4
0
        public async Task <IActionResult> EditServiceOrder(int?id)
        {
            List <Status> status = new List <Status>();

            status.Add(new Status {
                Id = 0, Name = "U obradi"
            });
            status.Add(new Status {
                Id = 1, Name = "Čeka dijelove"
            });
            status.Add(new Status {
                Id = 2, Name = "Čeka preuzimanje"
            });
            status.Add(new Status {
                Id = 3, Name = "Preuzet"
            });

            if (id == null)
            {
                return(NotFound());
            }
            var order = await _db.ServiceOrder.FindAsync(id);

            if (order == null)
            {
                return(NotFound());
            }

            ServiceOrderVM orderVM = new ServiceOrderVM()
            {
                CustomerList = await _db.AppUser.OrderBy(i => i.Name).Where(i => i.Customer == 1).ToListAsync(),
                StatusList   = status,
                ServiceOrder = order
            };

            return(View(orderVM));
        }