Пример #1
0
        public IActionResult Index()
        {
            var viewModel = new RemovePartViewModel
            {
                AllParts = this.removePartService.GetAllParts(),
            };

            var model = new RemovePartBaseModel
            {
                RemovePartInputModel = new RemovePartInputModel(),
                RemovePartViewModel  = viewModel,
            };

            return(this.View(model));
        }
Пример #2
0
        public async Task <IActionResult> RemovePart(RemovePartBaseModel model)
        {
            if (this.ModelState.IsValid)
            {
                string partName = await this.removePartService.RemovePart(model.RemovePartInputModel.Id);

                this.TempData["Success"] = string.Format(
                    MessageConstants.SuccessfullyRemovePart,
                    partName.ToUpper());
                return(this.RedirectToAction("Index", "RemovePart"));
            }
            else
            {
                this.TempData["Error"] = MessageConstants.InvalidInputModel;
                return(this.RedirectToAction("Index", "RemovePart", model));
            }
        }