public ActionResult Create() { var editViewModel = new EditViewModel { CompanyId = 0, CompanyName = string.Empty, }; return View("Edit", editViewModel); }
public ActionResult Save(EditViewModel editFormModel) { if (ModelState.IsValid) { Mapper.CreateMap<EditViewModel, Company>() .ForMember(dest => dest.CashBackPercentaje, opt => opt.MapFrom(src => src.CashBackPercentage)) .ForMember(dest => dest.CompanyName, opt => opt.MapFrom(src => src.CompanyName.ToUpper())) .ForMember(dest => dest.CompanyNickName, opt => opt.MapFrom( src => src.CompanyNickname != null ? src.CompanyNickname.ToUpper() : string.Empty)) .ForMember(dest => dest.CorporateId, opt => opt.MapFrom( src => src.CorporateId != null ? src.CorporateId.Replace("-", string.Empty) : string.Empty)); var company = Mapper.Map<EditViewModel, Company>(editFormModel); _companiesManagement.Save(company); return RedirectToAction("Index"); } return View("Edit", editFormModel); }