public ActionResult Create(InflationRateModel model) { try { if (TypeNameExist(model.Entity.OrgID ?? 0, model.Entity.InflationYear ?? 0, model.Entity.ID)) { ModelState.AddModelError("", "Inflation Rate Already Exist"); } if (ModelState.IsValid) { var certGrade = model.Entity; certGrade.ModifiedBy = User.Identity.Name; certGrade.ModifiedDate = DateTime.Now; certGrade.CreatedBy = User.Identity.Name; certGrade.CreatedDate = DateTime.Now; _unitOfWork.InflationRateRepository.Insert(certGrade); _unitOfWork.Save(); TempData["message"] = "<b>" + certGrade.InflationYear + "</b> was successfully created"; 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.InflationRateRepository.GetByID(id); if (certGrade == null) { return(HttpNotFound()); } var model = new InflationRateModel { 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 InflationRateModel { Entity = new InflationRate(), 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 <InflationRate> rowsToShow; int totalRecords; if (!string.IsNullOrEmpty(keywords)) { rowsToShow = _unitOfWork.InflationRateRepository.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.InflationRateRepository.Get(filter: x => x.OrgID == orgId && x.Organisation.Name.ToUpper().Contains(keywords.Trim().ToUpper())).Count(); } else { rowsToShow = _unitOfWork.InflationRateRepository.Get(filter: x => x.OrgID == orgId, orderBy: q => q.OrderBy(x => x.ID)).Skip((page - 1) * pgsize).Take(pgsize).ToList(); totalRecords = _unitOfWork.InflationRateRepository.Get(filter: x => x.OrgID == orgId, orderBy: q => q.OrderBy(x => x.ID)).Count(); } var model = new InflationRateModel() { 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" })); } }