/// <summary> /// add new invoice master. /// </summary> /// <returns></returns> public async Task <IActionResult> AddInvoiceMaster() { ViewBag.CustomerList = await _ledger.GetLedgerSelectList((int)LedgerName.SundryDebtor); ViewBag.BankLedgerList = await _ledger.GetLedgerSelectList((int)LedgerName.BankAccount); ViewBag.AccountLedgerList = await _ledger.GetLedgerSelectList(0); ViewBag.TaxRegisterList = await _taxRegister.GetTaxRegisterSelectList(); ViewBag.CurrencyList = await _currency.GetCurrencySelectList(); ViewBag.TaxModelTypeList = EnumHelper.GetEnumListFor <TaxModelType>(); ViewBag.DiscountTypeList = EnumHelper.GetEnumListFor <DiscountType>(); UserSessionModel userSession = SessionExtension.GetComplexData <UserSessionModel>(HttpContext.Session, "UserSession"); SalesInvoiceModel salesInvoiceModel = new SalesInvoiceModel(); salesInvoiceModel.CompanyId = userSession.CompanyId; salesInvoiceModel.FinancialYearId = userSession.FinancialYearId; // generate no. GenerateNoModel generateNoModel = await _salesInvoice.GenerateInvoiceNo(userSession.CompanyId, userSession.FinancialYearId); salesInvoiceModel.InvoiceNo = generateNoModel.VoucherNo; salesInvoiceModel.InvoiceDate = DateTime.Now; return(await Task.Run(() => { return PartialView("_AddInvoiceMaster", salesInvoiceModel); })); }
/// <summary> /// override save changes async /// </summary> /// <param name="acceptAllChangesOnSuccess"></param> /// <param name="cancellationToken"></param> /// <returns></returns> public override async Task <int> SaveChangesAsync(bool acceptAllChangesOnSuccess, CancellationToken cancellationToken = default(CancellationToken)) { try { UserSessionModel userSessionModel = SessionExtension.GetComplexData <UserSessionModel>(_session, "UserSession"); var changeSet = ChangeTracker.Entries <IAuditable>(); if (null != changeSet) { foreach (var entry in changeSet.Where(c => c.State != EntityState.Unchanged)) { switch (entry.State) { case EntityState.Added: if (entry.Entity.GetType().GetProperty("PreparedByUserId") != null) { entry.Property("PreparedByUserId").CurrentValue = userSessionModel.UserId; } if (entry.Entity.GetType().GetProperty("PreparedDateTime") != null) { entry.Property("PreparedDateTime").CurrentValue = DateTime.Now; } if (entry.Entity.GetType().GetProperty("UpdatedByUserId") != null) { entry.Property("UpdatedByUserId").CurrentValue = userSessionModel.UserId; } if (entry.Entity.GetType().GetProperty("UpdatedDateTime") != null) { entry.Property("UpdatedDateTime").CurrentValue = DateTime.Now; } break; case EntityState.Modified: if (entry.Entity.GetType().GetProperty("UpdatedByUserId") != null) { entry.Property("UpdatedByUserId").CurrentValue = userSessionModel.UserId; } if (entry.Entity.GetType().GetProperty("UpdatedDateTime") != null) { entry.Property("UpdatedDateTime").CurrentValue = DateTime.Now; } break; default: // dont' update anything. break; } } } return(await base.SaveChangesAsync(true, cancellationToken)); } catch (Exception ex) { throw; } }
public async Task <JsonResult> ChooseCommpany(int companyId) { JsonData <JsonStatus> data = new JsonData <JsonStatus>(new JsonStatus()); return(await Task.Run(() => { UserSessionModel userSessionModel = SessionExtension.GetComplexData <UserSessionModel>(HttpContext.Session, "UserSession"); userSessionModel.CompanyId = companyId; SessionExtension.SetComplexData(HttpContext.Session, "UserSession", userSessionModel); return Json(data); })); }
public async Task <PartialViewResult> AddVoucherSetupDetail() { VoucherSetupDetailModel voucherSetupDetailModel = new VoucherSetupDetailModel(); ViewBag.VoucherSetupList = await _voucherSetup.GetVoucherSetupSelectList(); ViewBag.VoucherStyleList = await _voucherStyle.GetVoucherStyleSelectList(); UserSessionModel userSession = SessionExtension.GetComplexData <UserSessionModel>(HttpContext.Session, "UserSession"); voucherSetupDetailModel.CompanyId = userSession.CompanyId; voucherSetupDetailModel.FinancialYearId = userSession.FinancialYearId; return(PartialView("_AddVoucherSetupDetail", voucherSetupDetailModel)); }
public IActionResult Index() { UserSessionModel userSessionModel = SessionExtension.GetComplexData <UserSessionModel>(HttpContext.Session, "UserSession"); return(View()); }