public ActionResult CompanyAdd(CompanyConfigModel item) { if (ModelState.IsValid) { try { Company company = new Company() { CompanyName = item.CompanyName, CompanyInsuranceRatePercent = item.CompanyInsuranceRatePercent, LabaratorInsuranceRatePercent = item.LabaratorInsuranceRatePercent, NumberCodeStarRange = item.NumberCodeStarRange, NumberCodeEndRange = item.NumberCodeEndRange, CompanyCode = item.CompanyCode }; companyService.CreateCompany(company); } catch (Exception e) { ViewData["EditError"] = e.Message; } } else ViewData["EditError"] = "Xin vui lòng kiểm tra lại dữ liệu nhập."; var companies = companyService.GetCompanies(); var companiesView = Mapper.Map<IEnumerable<Company>, IEnumerable<CompanyConfigModel>>(companies); return PartialView("Company/_CompanyGridViewPartial", companiesView); }
public ActionResult CompanyUpdate(CompanyConfigModel item) { if (ModelState.IsValid) { try { Company company = companyService.GetCompany(item.Id); if (company != null) { company.CompanyName = item.CompanyName; company.LabaratorInsuranceRatePercent = item.LabaratorInsuranceRatePercent; company.CompanyInsuranceRatePercent = item.CompanyInsuranceRatePercent; companyService.SaveCompany(); } else { ViewData["EditError"] = "Không tồn tại công ty"; } } catch (Exception e) { ViewData["EditError"] = e.Message; } } else ViewData["EditError"] = "Xin vui lòng kiểm tra lại dữ liệu nhập."; var companies = companyService.GetCompanies(); var companiesView = Mapper.Map<IEnumerable<Company>, IEnumerable<CompanyConfigModel>>(companies); return PartialView("Company/_CompanyGridViewPartial", companiesView); }