public ActionResult Edit(DiscountRateModel model) { try { if (ModelState.IsValid) { var certGrade = model.Entity; certGrade.ModifiedBy = User.Identity.Name; certGrade.ModifiedDate = DateTime.Now; _unitOfWork.DiscountRateRepository.Update(certGrade); _unitOfWork.Save(); TempData["message"] = "<b>" + certGrade.DiscountYear + "</b> was successfully updated"; return(RedirectToAction("Index", new { orgId = model.Entity.OrgID })); } model.OrgLookUp = LookUps.OrganisationById(model.Entity.OrgID ?? 0); return(View(model)); } catch (Exception ex) { // Log with Elmah Elmah.ErrorSignal.FromCurrentContext().Raise(ex); TempData["message"] = Settings.Default.GenericExceptionMessage; return(RedirectToAction("Index", "Home", new { area = "Admin" })); } }
public ActionResult Edit(int id = 0) { try { var certGrade = _unitOfWork.DiscountRateRepository.GetByID(id); if (certGrade == null) { return(HttpNotFound()); } var model = new DiscountRateModel { Entity = certGrade, OrgLookUp = LookUps.OrganisationById(certGrade.OrgID ?? 0), orgID = certGrade.OrgID ?? 0 }; return(View(model)); } catch (Exception ex) { // Log with Elmah Elmah.ErrorSignal.FromCurrentContext().Raise(ex); TempData["message"] = Settings.Default.GenericExceptionMessage; return(RedirectToAction("Index", "Home", new { area = "Admin" })); } }
public ActionResult Create(int orgId) { var model = new DiscountRateModel { Entity = new DiscountRate(), OrgLookUp = LookUps.OrganisationById(orgId), orgID = orgId }; return(View(model)); }
public ActionResult Index([DefaultValue(1)] int page, string keywords, [DefaultValue(10)] int pgsize) { try { var orgId = LookUps.GetOrgId(User.Identity.Name); if (orgId == 0) { orgId = Settings.Default.DefaultOrgId; } List <DiscountRate> rowsToShow; int totalRecords; if (!string.IsNullOrEmpty(keywords)) { rowsToShow = _unitOfWork.DiscountRateRepository.Get(filter: x => x.OrgID == orgId && x.Organisation.Name.ToUpper().Contains(keywords.Trim().ToUpper()), orderBy: q => q.OrderBy(x => x.ID)).Skip((page - 1) * pgsize).Take(pgsize).ToList(); totalRecords = _unitOfWork.DiscountRateRepository.Get(filter: x => x.OrgID == orgId && x.Organisation.Name.ToUpper().Contains(keywords.Trim().ToUpper())).Count(); } else { rowsToShow = _unitOfWork.DiscountRateRepository.Get(filter: x => x.OrgID == orgId, orderBy: q => q.OrderBy(x => x.ID)).Skip((page - 1) * pgsize).Take(pgsize).ToList(); totalRecords = _unitOfWork.DiscountRateRepository.Get(filter: x => x.OrgID == orgId, orderBy: q => q.OrderBy(x => x.ID)).Count(); } var model = new DiscountRateModel() { Rows = rowsToShow, orgID = orgId, PagingInfo = new PagingInfo { FirstItem = ((page - 1) * pgsize) + 1, LastItem = page * pgsize, CurrentPage = page, ItemsPerPage = pgsize, TotalItems = totalRecords }, CurrentKeywords = keywords, PageSize = pgsize }; return(View(model)); } catch (Exception ex) { // Log with Elmah Elmah.ErrorSignal.FromCurrentContext().Raise(ex); TempData["message"] = Settings.Default.GenericExceptionMessage; return(RedirectToAction("Index", "Home", new { area = "Admin" })); } }