public async Task <ActionResult> AddOrEditBank(BankDetailModel bank)
        {
            if (bank.BankCancelledChequeFilePath != null && bank.BankCancelledChequeFileName != null)
            {
                if (System.IO.File.Exists(Server.MapPath(_path + "Banks/" + bank.BankCancelledChequeFileName)))
                {
                    System.IO.File.Delete(Server.MapPath(_path + "Banks/" + bank.BankCancelledChequeFileName));
                }
            }

            if (bank.BankCancelledChequeFilePath != null)
            {
                bank.BankCancelledChequeFileName = SaveImageFile(bank.BankCancelledChequeFilePath, "Banks");
            }
            if (bank.bankId != null)
            {
                bank.EventAction = 'U';
            }
            else
            {
                bank.EventAction = 'I';
            }
            bank.UserId = CurrentUser.UserId;
            if (TempData["client"] != null)
            {
                var Client = TempData["client"] as ClientModel;
                bank.RefKey = Client.ClientId;
            }
            var response = await _bank.AddUpdateBankDetails(bank);

            TempData["response"] = response;
            if (TempData["client"] != null)
            {
                var Client = TempData["client"] as ClientModel;
                bank.bankId = new Guid(response.result);
                var name = Client.Bank.BankList.Where(x => x.Value == bank.BankNameId.ToString()).FirstOrDefault();
                bank.BankName = name.Text;
                Client.BankDetails.Add(bank);
                Client.action      = 'I';
                Client.Activetab   = "tab-5";
                TempData["client"] = Client;
                return(View("Create", Client));
            }
            else
            {
                var Client = await GetClient(bank.RefKey);

                Client.action    = 'U';
                Client.Activetab = "tab-4";
                return(View("Edit", Client));
            }
        }
Пример #2
0
        public async Task <ActionResult> AddOrEditBank(BankDetailModel bank)
        {
            if (bank.BankCancelledChequeFileName != null && bank.BankCancelledChequeFilePath != null)
            {
                if (System.IO.File.Exists(Server.MapPath(_path + "Cheques/" + bank.BankCancelledChequeFileName)))
                {
                    System.IO.File.Delete(Server.MapPath(_path + "Cheques/" + bank.BankCancelledChequeFileName));
                }
            }

            if (bank.BankCancelledChequeFilePath != null)
            {
                bank.BankCancelledChequeFileName = SaveImageFile(bank.BankCancelledChequeFilePath, "Cheques/");
            }
            if (bank.bankId == null)
            {
                bank.EventAction = 'I';
            }
            else
            {
                bank.EventAction = 'U';
            }
            CompanyModel comp = new CompanyModel();

            if (TempData["Comp"] != null)
            {
                comp           = TempData["Comp"] as CompanyModel;
                comp.ActiveTab = "tab-5";
                comp.Action    = 'I';
                comp.BankDetails.Add(bank);
                comp.Agreement = new AgreementModel
                {
                    ServiceList         = await CommonModel.GetServiceType(new FilterModel()),
                    DeliveryServiceList = await CommonModel.GetDeliveryServiceType(new FilterModel())
                };
                comp.BankDetail = new BankDetailModel {
                    RefKey   = comp.CompanyId,
                    BankList = new SelectList(await CommonModel.GetLookup("Bank"), "Value", "Text")
                };
                TempData["Comp"] = comp;
            }
            else
            {
                comp.Action = 'U';
            }
            bank.UserId = CurrentUser.UserId;
            var response = await _BankRepo.AddUpdateBankDetails(bank);

            TempData["response"] = response;
            if (comp.Action == 'I')
            {
                return(View("Create", comp));
            }
            else
            {
                comp = await GetCompany(bank.RefKey);

                comp.ActiveTab = "tab-4";
                return(View("Edit", comp));
            }
        }