public ActionResult CreateAccount(GLAccountViewModel generalLedgerAccountViewModel) { if (!ModelState.IsValid) { var branches = _context.Branches.ToList(); var GlCategories = _context.GlCategories.ToList(); var viewModel = new GLAccountViewModel() { Branch = branches, GLCategories = GlCategories, GlAccount = new GLAccount() }; return(View("GLAccount", viewModel)); } var generalLedgerAccount = new GLAccount { GlCategoriesId = generalLedgerAccountViewModel.GlAccount.GlCategoriesId, BranchId = generalLedgerAccountViewModel.GlAccount.BranchId, Name = generalLedgerAccountViewModel.GlAccount.Name, Id = generalLedgerAccountViewModel.GlAccount.Id, Code = getCode(generalLedgerAccountViewModel.GlAccount.GlCategoriesId) }; //Mapper.Map(generalLedgerCategoryViewModel, generalLedgerCategory); _context.GlAccounts.Add(generalLedgerAccount); _context.SaveChanges(); return(RedirectToAction("Account", "GeneralLedgers")); }
public ActionResult Edit(GLAccountViewModel model) { ViewData["Branches"] = context.Branches.ToList(); ViewData["GLCategories"] = context.GLCategories.ToList(); if (ModelState.IsValid) { GLAccount glAccount = context.GLAccounts.Find(model.Id); glAccount.Name = model.Name; glAccount.Branch = context.Branches.Find(model.BranchID); context.SaveChanges(); return(RedirectToAction("Index")); } return(View(model)); }
public ActionResult Create(GLAccountViewModel model) { ViewData["Branches"] = context.Branches.ToList(); ViewData["GLCategories"] = context.GLCategories.ToList(); if (ModelState.IsValid) { GLAccount glAccount = new GLAccount(); glAccount.AccNo = Helper.GenerateGLAccNo(model.GLCategoryID); glAccount.Name = model.Name; glAccount.Balance = model.Balance; glAccount.Branch = context.Branches.Find(model.BranchID); glAccount.GLCategory = context.GLCategories.Find(model.GLCategoryID); context.GLAccounts.Add(glAccount); context.SaveChanges(); return(RedirectToAction("Index")); } return(View(model)); }
// GET: GeneralLedgers/Account public ActionResult Account() { ViewBag.Message = RoleName.USER_NAME; var glCategory = _context.GlCategories.ToList(); var branches = _context.Branches.ToList(); var count = _context.GlAccounts.Count(); var viewModel = new GLAccountViewModel() { GlAccount = new GLAccount(), GLCategories = glCategory, Branch = branches, count = count }; if (User.IsInRole(RoleName.ADMIN_ROLE)) { return(View("GLAccount", viewModel)); } return(View("AccountReadOnly", viewModel)); }
// GET: GLAccount/Edit/5 public ActionResult Edit(int?id) { ViewData["Branches"] = context.Branches.ToList(); ViewData["GLCategories"] = context.GLCategories.ToList(); if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } GLAccount glAccount = context.GLAccounts.Find(id); if (glAccount == null) { return(HttpNotFound()); } GLAccountViewModel model = new GLAccountViewModel(); model.Name = glAccount.Name; model.BranchID = glAccount.Branch.ID; return(View(model)); }