public ActionResult Edit(AccountValueViewModel model) { if (ModelState.IsValid) { try { if (model.Value.Length != model.ValueChar) { ModelState.AddModelError("Error", "Invalid Value character length."); } else if (model.StartDate != null && model.StartDate > model.EndDate) { ModelState.AddModelError("Error", "End Date should be greater than StartDate."); } else { string result = AccountValueHelper.SaveChartOfAccountValue(model); return(RedirectToAction("Index", new { id = SessionHelper.SOBId })); } } catch (Exception ex) { ModelState.AddModelError("Error", ex.InnerException.InnerException.Message); } } return(View(model)); }
private static AccountValue getEntityByModel(AccountValueViewModel model) { if (model == null) { return(null); } AccountValue entity = new AccountValue(); entity.AccountType = model.AccountType; entity.ChartId = model.ChartId; entity.EndDate = model.EndDate; entity.Id = model.Id; entity.Levl = model.Levl; entity.Segment = model.Segment; entity.StartDate = model.StartDate; if (model.Id == 0) { entity.CreateDate = DateTime.Now; entity.CreateBy = AuthenticationHelper.UserId; entity.CompanyId = AuthenticationHelper.CompanyId.Value; } else { entity.CreateBy = model.CreateBy; entity.CreateDate = model.CreateDate; entity.CompanyId = model.CompanyId; } entity.UpdateBy = AuthenticationHelper.UserId; entity.UpdateDate = DateTime.Now; entity.Value = model.Value; entity.ValueName = model.ValueName; return(entity); }
public ActionResult Edit(long id) { AccountValueViewModel model = new AccountValueViewModel(service.GetSingle(id.ToString(), AuthenticationHelper.User.CompanyId)); model.SetOfBook = sobService.GetSingle(accountService.GetSingle(model.ChartId.ToString(), AuthenticationHelper.User.CompanyId).SOBId.ToString(), AuthenticationHelper.User.CompanyId).Name; return(View(model)); }
public static string SaveChartOfAccountValue(AccountValueViewModel model) { if (model.Id > 0) { return(service.Update(getEntityByModel(model))); } else { return(service.Insert(getEntityByModel(model))); } }
public ActionResult Create(long sobId, string segment) { AccountValueViewModel model = new AccountValueViewModel(); if (accountService.GetAccountBySOBId(sobId.ToString(), AuthenticationHelper.User.CompanyId) != null) { model.ChartId = accountService.GetAccountBySOBId(sobId.ToString(), AuthenticationHelper.User.CompanyId).Id; model.SetOfBook = sobService.GetSingle(sobId.ToString(), AuthenticationHelper.User.CompanyId).Name; model.Segment = segment; return(View("Edit", model)); } return(RedirectToAction("Index")); }
public ActionResult Edit(string id) { if (!AccountValueHelper.CheckAccountValue(id)) { throw new Exception("Edit Error", new Exception { Source = "Values having code combinitions cannot be edited" }); } AccountValueViewModel model = AccountValueHelper.GetAccountValue(id); model.SetOfBook = SetOfBookHelper.GetSetOfBook(SessionHelper.SOBId.ToString()).Name; model.ValueChar = AccountHelper.GetSegmentCharacters(model.Segment, AccountHelper.GetAccountBySOBId(SessionHelper.SOBId.ToString())); return(View(model)); }
public ActionResult Create(string segment) { AccountValueViewModel model = new AccountValueViewModel(); Account account = AccountHelper.GetAccountBySOBId(SessionHelper.SOBId.ToString()); if (account != null) { model.ChartId = account.Id; model.SetOfBook = SetOfBookHelper.GetSetOfBook(SessionHelper.SOBId.ToString()).Name; model.Segment = segment; SessionHelper.SelectedValue = segment; model.ValueChar = AccountHelper.GetSegmentCharacters(segment, account); return(View("Edit", model)); } return(RedirectToAction("Index")); }
private AccountValue mapModel(AccountValueViewModel model) ////TODO: this should be done in service will discuss later - FK { return(new AccountValue { AccountType = model.AccountType, ChartId = model.ChartId, CreateDate = DateTime.Now, EndDate = model.EndDate, Id = model.Id, Levl = model.Levl, Segment = model.Segment, StartDate = model.StartDate, UpdateDate = DateTime.Now, Value = model.Value, ValueName = model.ValueName }); }
public ActionResult Edit(AccountValueViewModel model) { if (ModelState.IsValid) { if (model.Id > 0) { string result = service.Update(mapModel(model)); return(RedirectToAction("Index")); } else { string result = service.Insert(mapModel(model)); return(RedirectToAction("Index")); } } return(View(model)); }
public ActionResult Create([Bind(Include = "Id,MonthlyBalance,MonthYear,PortfolioAccountId")] AccountValueViewModel model) { if (ModelState.IsValid) { var accountVal = Mapper.Map <AccountValue>(model); _unitOfWork.AccountValues.Add(accountVal); _unitOfWork.Complete(); return(RedirectToAction("Index")); } var userId = User.Identity.GetUserId(); var accounts = _unitOfWork .PortfolioAccounts.GetAll(p => p.OwnerId == userId, p => p.AccountType) .Select(s => new { Id = s.Id, Description = $"{s.AccountNumber} - {s.AccountHolder} - {s.FinancialInstitution} - {s.AccountType.Name}", }) .ToList(); ViewBag.PortfolioAccountId = new SelectList(accounts, "Id", "Description", model.PortfolioAccountId); return(View(model)); }