//GET: GlCategory/Details/{id} public ActionResult Details(int?id) { if (id == null) { return(HttpNotFound()); } GlCategoryManagement category = _category.Get(id); if (category == null) { return(HttpNotFound()); } return(View(category)); }
public ActionResult Edit(GlCategoryManagement category) { if (category.Id == 0) { _category.Save(category); } else { var categoryInDb = _category.Get(category.Id); var getGlCat = _glAccount.GetCatName(categoryInDb.Name); var glAccount = _glAccount.Get(getGlCat.Id); categoryInDb.Name = Request.Form["catName"]; categoryInDb.Description = Request.Form["catDescription"]; glAccount.CategoryManagementId = categoryInDb.Name; _category.Update(category); _glAccount.Update(glAccount); } return(RedirectToAction("Index", "GlCategoryManagement")); }
//GET: GlCategory/Edit/{id} public ActionResult Edit(int?id) { if (id != null) { GlCategoryManagement category = _category.Get(id); GlCategoryManagementViewModels viewModel = new GlCategoryManagementViewModels { MainCategory = _category.GetAllMainAccountCategories(), GlCategoryManagements = category }; if (category != null) { return(View(viewModel)); } return(HttpNotFound()); } return(HttpNotFound()); }
public ActionResult Create(GlCategoryManagement category) { category.Name = Request.Form["catName"]; category.Description = Request.Form["catDescription"]; category.MainAccountCategoryId = Request.Form["catCategory"]; try { if (!Logic.IsGlNameExist(Request.Form["catName"])) { //Adding information into database //db.Entry(category).State = EntityState.Modified; _category.Add(category); //Saving information into database _category.Save(category); return(RedirectToAction("Index", "GlCategoryManagement")); } ViewBag.Message = "Gl Category Name Already Exist"; } catch (DbEntityValidationException ex) { var errorMessages = ex.EntityValidationErrors .SelectMany(x => x.ValidationErrors) .Select(x => x.ErrorMessage); var fullErrorMessage = string.Join("; ", errorMessages); var exceptionMessage = string.Concat(ex.Message, " The validation errors are: ", fullErrorMessage); throw new DbEntityValidationException(exceptionMessage, ex.EntityValidationErrors); } return(View(ViewModel)); }