public async Task <IActionResult> Update(PartUpdateInputModel inputModel) { if (this.User.IsInRole(GlobalConstants.AdministratorRoleName)) { if (!this.ModelState.IsValid) { return(this.Redirect("/Part/Index")); } var isSamePart = await this.partService.IsSamePartAsync( inputModel.PartName, inputModel.BrandAndModelName, inputModel.CategoryName, inputModel.ManufactoryName, inputModel.Quantity, inputModel.Price); if (isSamePart) { return(this.Redirect("/Part/Error")); } var partDto = PartUpdateInputMapper.Map(inputModel); await this.partService.UpdatePartAsync(partDto); return(this.Redirect("/Part/Index")); } return(this.Redirect("/Identity/Account/AccessDenied")); }
public static PartUpdateInputDtoModel Map(PartUpdateInputModel model) { var partDto = new PartUpdateInputDtoModel { PartId = model.PartId, PartName = model.PartName, BrandAndModelName = model.BrandAndModelName, CategoryName = model.CategoryName, ManufactoryName = model.ManufactoryName, Price = model.Price, Quantity = model.Quantity, }; return(partDto); }