public async Task <ActionResult> UpdateAdmin(ShutdownRequestModel model)
        {
            if (_workContext.CurrentUser == null)
            {
                return(AccessDeniedView());
            }

            DateTime baseDate;

            if (model.BasePlanDate.Length > 10)
            {
                baseDate = DateTime.ParseExact(model.BasePlanDate.Substring(0, 24),
                                               "ddd MMM d yyyy HH:mm:ss",
                                               CultureInfo.InvariantCulture);
            }
            else
            {
                baseDate = Convert.ToDateTime(model.BasePlanDate);
            }

            var userUpdate = await _userService.GetUserByIdAsync(model.UserCreatedId);

            if (userUpdate != null)
            {
                var shutdownRequest = await _shutdownRequestService.GetByIdAsync(model.Id);

                if (shutdownRequest != null)
                {
                    shutdownRequest.UpdatedDate            = DateTime.Now;
                    shutdownRequest.Comment                = model.Comment;
                    shutdownRequest.MakingScope            = model.MakingScope;
                    shutdownRequest.PackingScope           = model.PackingScope;
                    shutdownRequest.Remark                 = model.Remark;
                    shutdownRequest.ShutdownRequestContent = model.Content;
                    shutdownRequest.BasePlanDate           = baseDate;
                    shutdownRequest.ShutdownStatus         = (ShutdownStatus)model.StatusId;
                    if (shutdownRequest.UserCreatedId != userUpdate.Id)
                    {
                        shutdownRequest.UserCreatedId = userUpdate.Id;
                        shutdownRequest.CreatedUser   = userUpdate;
                    }

                    await _shutdownRequestService.UpdateAsync(shutdownRequest);
                }
            }


            return(new NullJsonResult());
        }
        public async Task <ActionResult> Create(ShutdownRequestModel model)
        {
            if (_workContext.CurrentUser == null)
            {
                return(AccessDeniedView());
            }

            DateTime baseDate;
            var      userCreate = await _userService.GetUserByIdAsync(model.UserCreatedId);

            if (model.BasePlanDate.Length > 10)
            {
                baseDate = DateTime.ParseExact(model.BasePlanDate.Substring(0, 24),
                                               "ddd MMM d yyyy HH:mm:ss",
                                               CultureInfo.InvariantCulture);
            }
            else
            {
                baseDate = Convert.ToDateTime(model.BasePlanDate);
            }

            var shutdownRequest = new ShutdownRequest
            {
                Comment                = model.Comment,
                CreatedDate            = DateTime.Now,
                UpdatedDate            = DateTime.Now,
                MakingScope            = model.MakingScope,
                PackingScope           = model.PackingScope,
                BasePlanDate           = baseDate,
                ShutdownRequestContent = model.Content,
                Remark         = model.Remark,
                CreatedUser    = userCreate,
                UserCreatedId  = userCreate.Id,
                ShutdownStatus = (ShutdownStatus)model.StatusId
            };
            await _shutdownRequestService.InsertAsync(shutdownRequest);

            return(new NullJsonResult());
        }