public JsonResult AddUpdateBranch(int BankId, int BranchId, int BranchCountryId, string BranchName, string BranchPhoneNumber, string BranchAddress, string ContactPhoneNo, string ContactPerson, string ContactEmail) { bool check = _bankmanagementser.VerifyBranchInput(BankId, BranchName, BranchAddress, BranchCountryId, BranchPhoneNumber); if (check == true) { if (BranchId == 0) { BranchManagementsModel model = new BranchManagementsModel { BankId = BankId, BankBranchId = BranchId, BranchCountryId = BranchCountryId, BranchName = BranchName, BranchPhoneNumber = BranchPhoneNumber, BranchAddress = BranchAddress, BranchContactPhoneNo = ContactPhoneNo, BranchContactPerson = ContactPerson, BranchContactEmail = ContactEmail }; _bankmanagementser.CreateBranch(model); model.BankBranchId = _bankmanagementser.GetLastBranchId(model.BankId); BranchManagementsModel item = _bankmanagementser.GetBranchDetails(model.BankBranchId); JsonResult result = new JsonResult(); result.Data = item; return(result); } else { BranchManagementsModel model = new BranchManagementsModel { BankId = BankId, BankBranchId = BranchId, BranchCountryId = BranchCountryId, BranchName = BranchName, BranchPhoneNumber = BranchPhoneNumber, BranchAddress = BranchAddress, BranchContactPhoneNo = ContactPhoneNo, BranchContactPerson = ContactPerson, BranchContactEmail = ContactEmail }; _bankmanagementser.BranchUpdate(model); BranchManagementsModel item = _bankmanagementser.GetBranchDetails(model.BankBranchId); JsonResult result = new JsonResult(); result.Data = item; return(result); } } else { JsonResult answer = new JsonResult(); answer.Data = null; return(answer); } }
public void BranchUpdate(BranchManagementsModel model) { BankBranches result = ent.BankBranches.Where(x => x.BankBranchId == model.BankBranchId).FirstOrDefault(); result.BranchAddress = model.BranchAddress; result.BranchName = model.BranchName; result.ContactPerson = model.BranchContactPerson; result.PhoneNumber = model.BranchPhoneNumber; result.ContactPersonPhoneNo = model.BranchContactPhoneNo; result.ContactPersonEmail = model.BranchContactEmail; result.CountryId = model.BranchCountryId; ent.ApplyCurrentValues(result.EntityKey.EntitySetName, result); ent.SaveChanges(); }
public BranchManagementsModel ConverToBranch(BankManagementsModel model) { BranchManagementsModel item = new BranchManagementsModel { BankId = model.BankId, BranchAddress = model.BranchAddress, CountryId = model.BranchCountryId, BranchName = model.BranchName, BranchPhoneNumber = model.BranchPhoneNumber, BranchContactPerson = model.BranchContactPerson, BranchContactEmail = model.BranchContactEmail, BranchContactPhoneNo = model.BranchContactPhoneNo, }; return(item); }
public void CreateBranch(BranchManagementsModel model) { BankBranches obj = new BankBranches { BankId = model.BankId, BranchName = model.BranchName, BranchAddress = model.BranchAddress, CountryId = model.BranchCountryId, PhoneNumber = model.BranchPhoneNumber, ContactPerson = model.BranchContactPerson, ContactPersonPhoneNo = model.BranchContactPhoneNo, ContactPersonEmail = model.BranchContactEmail, }; ent.AddToBankBranches(obj); ent.SaveChanges(); }
public BranchManagementsModel GetBranchDetails(int BankBranchId) { BankBranches result = new BankBranches(); result = ent.BankBranches.Where(x => x.BankBranchId == BankBranchId).FirstOrDefault(); BranchManagementsModel model = new BranchManagementsModel { BranchName = result.BranchName, BranchAddress = result.BranchAddress, BranchContactPerson = result.ContactPerson, BranchContactEmail = result.ContactPersonEmail, BranchContactPhoneNo = result.ContactPersonPhoneNo, BranchPhoneNumber = result.PhoneNumber, BranchCountryId = result.CountryId, BankBranchId = result.BankBranchId, BankId = result.BankId, BankName = result.Banks.BankName }; return(model); }
//public IEnumerable<BankManagementsModel> GetBanksBranchList(int BankId) //{ // var result = from a in ent.BankBranches // where a.BankId == BankId // select new { a.BankId, a.BankBranchId, a.BranchAddress, a.BranchName, a.ContactPerson, a.ContactPersonEmail, a.ContactPersonPhoneNo, a.CountryId }; // List<BankManagementsModel> model = new List<BankManagementsModel>(); // foreach (var item in result) // { // } // return model; //} public IEnumerable <BranchManagementsModel> GetBranchOfBank(int BankId) { List <BranchManagementsModel> obj = new List <BranchManagementsModel>(); var result = ent.BankBranches.Where(x => x.BankId == BankId); foreach (var item in result) { BranchManagementsModel model = new BranchManagementsModel { BankBranchId = item.BankBranchId, CountryId = item.CountryId, BankId = item.BankId, BranchName = item.BranchName, BranchAddress = item.BranchAddress, BranchContactPerson = item.ContactPerson, BranchContactPhoneNo = item.ContactPersonPhoneNo, BranchPhoneNumber = item.PhoneNumber, BranchContactEmail = item.ContactPersonEmail, BankName = item.Banks.BankName }; obj.Add(model); } return(obj); }