public ActionResult Index_UpdateCurrentStatus(CurrentStatusViewModel model)
        {
            if (!ModelState.IsValid)
            {
                if (!ModelState.IsValidField(nameof(CurrentStatusViewModel.ScheduledWorkDate)))
                {
                    ModelState.AddModelError("", $"Дата была введена неверно");
                }
                else
                {
                    throw new HttpRequestValidationException();
                }

                return(View(model));
            }

            var now = DateTime.Now;

            if (model.StatusCode == StatusCode.WorkScheduled && model.ScheduledWorkDate < now)
            {
                ModelState.AddModelError("", $"Дата запланированных работ не может быть раньше текущего момента времени (Сейчас {now})");
                return(View(model));
            }

            // Если все ок, обновляем текущий статус
            _casketStatusRepository.CurrentStatus = new CurrentStatus()
            {
                Code = model.StatusCode, ScheduledWorkDate = model.ScheduledWorkDate
            };

            ViewBag.CurrentStatusUpdated = true; //< Чтобы вьюшка видела, что статус был обновлен
            return(View(model));
        }
Exemple #2
0
        public ActionResult StatusChange(int?id)
        {
            if (id == null)
            {
                return(HttpNotFound());
            }

            COMPONENT component = componentRepository.GetAllList().
                                  FirstOrDefault(x => x.ID.Equals(Convert.ToDecimal(id)));

            if (component == null)
            {
                return(HttpNotFound());
            }

            decimal status = component.CURRENT_STATUS.Where(x => x.ID_COMPLECT.Equals(component.ID))
                             .OrderByDescending(x => x.DATE_STATUS).FirstOrDefault().ID_STATUS;
            string statusName = component.CURRENT_STATUS.Where(x => x.ID_COMPLECT.Equals(component.ID))
                                .OrderByDescending(x => x.DATE_STATUS).FirstOrDefault().STATUS.NAME;

            CurrentStatusViewModel modelData = new CurrentStatusViewModel()
            {
                ID          = component.ID,
                ID_COMPLECT = component.ID,
                ID_STATUS   = status,
                statusList  = getList.getStatusSelectList()
            };

            return(View(modelData));
        }
Exemple #3
0
        // GET: Index
        public ActionResult Index(int?page, CurrentStatusViewModel modelData)
        {
            if (modelData.searchString != null)
            {
                page = 1;
            }
            else
            {
                modelData.searchString = modelData.currentFilter;
            }

            modelData.currentFilter = modelData.searchString;

            IEnumerable <CURRENT_STATUS> CurLog = currentStatusRepository.GetAllList();

            if (!String.IsNullOrEmpty(modelData.searchString))
            {
                decimal searchDigit;
                bool    isInt = Decimal.TryParse(modelData.searchString, out searchDigit);

                if (isInt)
                {
                    CurLog = CurLog.Where(s => s.COMPONENT.Equals(searchDigit)).
                             OrderBy(s => s.DATE_STATUS);
                }
                else
                {
                    CurLog = CurLog.Where(s => s.STATUS.NAME.Contains(modelData.searchString)).
                             OrderBy(s => s.DATE_STATUS);
                }
            }

            if (modelData.firstDate != null)
            {
                CurLog = CurLog.Where(x => x.DATE_STATUS >= modelData.firstDate);
            }
            if (modelData.secondDate != null)
            {
                CurLog = CurLog.Where(x => x.DATE_STATUS <= modelData.secondDate);
            }

            int pageSize   = 10;
            int pageNumber = (page ?? 1);

            CurrentStatusViewModel model = new CurrentStatusViewModel()
            {
                CurList       = CurLog.ToPagedList(pageNumber, pageSize),
                currentFilter = modelData.currentFilter,
                searchString  = modelData.searchString,
                firstDate     = modelData.firstDate,
                secondDate    = modelData.secondDate
            };

            return(View(model));
        }
        public ActionResult Index()
        {
            CurrentStatusViewModel viewModel = new CurrentStatusViewModel();

            // Получаем текущий статус из БД
            var currentStatus = _casketStatusRepository.CurrentStatus;

            viewModel.StatusCode        = currentStatus.Code;
            viewModel.ScheduledWorkDate = currentStatus.ScheduledWorkDate;

            return(View(viewModel));
        }
Exemple #5
0
        public ActionResult StatusChange(CurrentStatusViewModel modelData)
        {
            if (ModelState.IsValid)
            {
                CURRENT_STATUS status = new CURRENT_STATUS()
                {
                    ID_COMPLECT = modelData.ID_COMPLECT,
                    ID_STATUS   = modelData.ID_STATUS,
                    DATE_STATUS = DateTime.Now
                };

                statusRepository.Create(status);
                statusRepository.Save();
                return(RedirectToAction("Index"));
            }
            else
            {
                return(HttpNotFound());
            }
        }