Example #1
0
        public IActionResult StartAService(int id, StartAServiceViewModel startAServiceViewModel)
        {
            int iD = 1;

            if (_context.ServiceOrder.Any() == false)
            {
                iD = 1;
            }
            else
            {
                var ID = _context.ServiceOrder.Last().id;
                iD += ID;
            }

            ServiceOrder serviceOrder = new ServiceOrder();

            serviceOrder.id = iD;

            var length = 8;
            var chars  = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
            var random = new Random();
            var result = new string(
                Enumerable.Repeat(chars, length)
                .Select(s => s[random.Next(s.Length)])
                .ToArray());

            serviceOrder.SerialCode  = result;
            serviceOrder.ClientID    = id;
            serviceOrder.ClientName  = _context.Client.Where(c => c.id == id).First().Name;
            serviceOrder.ProjectName = startAServiceViewModel.ProjectName;
            serviceOrder.Comments    = startAServiceViewModel.Comments;


            _serviceOrderService.StartAService(serviceOrder);
            return(RedirectToAction(nameof(Index)));
        }
Example #2
0
        //GET
        public IActionResult StartAService()
        {
            StartAServiceViewModel startAServiceViewModel = new StartAServiceViewModel();

            return(View(startAServiceViewModel));
        }