Example #1
0
        public IActionResult Index()
        {
            var viewModel = new EditPartViewModel
            {
                AllParts    = this.editPartService.GetAllParts(),
                AllSections = this.editPartService.GetAllSections(),
            };

            var model = new EditPartBaseModel
            {
                EditPartInputModel = new EditPartInputModel(),
                EditPartViewModel  = viewModel,
            };

            return(this.View(model));
        }
Example #2
0
        public async Task <IActionResult> EditPart(EditPartBaseModel model)
        {
            if (this.ModelState.IsValid)
            {
                await this.editPartService.EditPart(model.EditPartInputModel);

                this.TempData["Success"] = string.Format(
                    MessageConstants.SuccessfullyEditPart,
                    model.EditPartInputModel.Name);
                return(this.RedirectToAction("Index", "EditPart"));
            }
            else
            {
                this.TempData["Error"] = MessageConstants.InvalidInputModel;
                return(this.RedirectToAction("Index", "EditPart", model));
            }
        }