Ejemplo n.º 1
0
        public virtual ActionResult Add(int companyId)
        {
            var company = _companyByIdQuery.WithCompanyId(companyId).RequestedByUserId(CurrentUserId).Execute();
            if (company == null)
            {
                ViewBag.EntityType = "Position";
                return View(MVC.Shared.Views.EntityNotFound);
            }

            var model = new EditPositionViewModel
            {
                Company = Mapper.Map<Company, CompanySummaryViewModel>(company)
            };

            return View(MVC.Position.Views.Edit, model);
        }
Ejemplo n.º 2
0
        public virtual ActionResult Edit(EditPositionViewModel model)
        {
            PositionDisplayViewModel editedModel;
            model.RequestedUserId = CurrentUserId;

            if (string.IsNullOrWhiteSpace(model.Title))
            {
                model.Company = new CompanySummaryViewModel(_companyByIdQuery.WithCompanyId(model.Company.Id).Execute());
                return View(model);
            }

            try
            {
                if (model.Id == 0)
                    editedModel = _createProcess.Execute(Mapper.Map<EditPositionViewModel, CreatePositionParams>(model));
                else
                    editedModel = _editProcess.Execute(Mapper.Map<EditPositionViewModel, EditPositionParams>(model));
            }
            catch (UserNotAuthorizedForEntityException ex)
            {
                ViewBag.EntityType = ex.EntityType.Name;
                return View(MVC.Shared.Views.EntityNotFound);
            }

            return RedirectToAction(MVC.Position.Details(editedModel.Id));
        }