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 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(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); }
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 }; }