public ActionResult Edit(int id, HelicopterTaskEditModel editModel)
        {
            if (editModel.IsValid() == false)
            {
                Response.StatusCode = 500;
                return(PartialView("_ValidationErrorSummary", new ValidationErrorSummaryViewModel(editModel.GetValidationErrors())));
            }

            HelicopterTaskListItemViewModel viewModel = _helicopterTaskService.Edit(id, editModel);

            return(PartialView("_HelicopterTaskTableRow", viewModel));
        }
Пример #2
0
        public HelicopterTaskIndexViewModel Index()
        {
            IEnumerable <HelicopterTask> helicopterTasks = _helicopterTaskDAO.GetAllOrderedByType();

            var viewModel = new HelicopterTaskIndexViewModel();

            foreach (var helicopterTask in helicopterTasks)
            {
                var listItemViewModel = new HelicopterTaskListItemViewModel
                {
                    Id         = helicopterTask.Id,
                    Helicopter = helicopterTask.HelicopterType.Title,
                    Task       = helicopterTask.Task != null ? helicopterTask.Task.Title : helicopterTask.HelicopterType.Title,
                    NoiseLevel = helicopterTask.NoiseLevel
                };
                viewModel.HelicopterTasks.Add(listItemViewModel);
            }

            return(viewModel);
        }
Пример #3
0
        public HelicopterTaskListItemViewModel Edit(int id, HelicopterTaskEditModel editModel)
        {
            var helicopterTask = _helicopterTaskDAO.Get(id);

            helicopterTask.HelicopterType = _helicopterTypeDAO.Get(editModel.HelicopterTypeId);
            helicopterTask.Task           = _taskDAO.Get(editModel.TaskId);
            helicopterTask.NoiseLevel     = editModel.NoiseLevel;

            _helicopterTaskDAO.Store(helicopterTask);

            var viewModel = new HelicopterTaskListItemViewModel
            {
                Id         = helicopterTask.Id,
                Helicopter = helicopterTask.HelicopterType.Title,
                Task       = helicopterTask.Task.Title,
                NoiseLevel = helicopterTask.NoiseLevel
            };

            return(viewModel);
        }