public ActionResult Add(BusinessObjects.Models.Branch branch) { try { if (ModelState.IsValid) { branch.bankId = ((BusinessObjects.Models.User)Session["UserObj"]).bankId; BusinessAccessLayer.BALBranches.BALBranches bALBranches = new BusinessAccessLayer.BALBranches.BALBranches(); BusinessObjects.Models.ResultsEnum checkInserted = bALBranches.insertBranch(branch); if (checkInserted == BusinessObjects.Models.ResultsEnum.notInserted) { TempData["errorMsg"] = LangText.checkConnection; return(View()); } else if (checkInserted == BusinessObjects.Models.ResultsEnum.inserted) { return(RedirectToAction("Home", "Branches")); } else { ViewBag.errorMsg = LangText.somethingWentWrongAlert; return(RedirectToAction("Home", "Branches")); } } else { return(View()); } } catch (Exception ex) { ExceptionsWriter.saveExceptionToLogFile(ex); return(View("Error")); } }
public ActionResult Add(BusinessObjects.Models.Branch branch) { try { if (ModelState.IsValid) { ClaimsPrincipal principal = HttpContext.User as ClaimsPrincipal; branch.bankId = Convert.ToInt32(principal.FindFirst("BankId").Value); BusinessAccessLayer.BALBranches.BALBranches bALBranches = new BusinessAccessLayer.BALBranches.BALBranches(); BusinessObjects.Models.ResultsEnum checkInserted = bALBranches.insertBranch(branch); if (checkInserted == BusinessObjects.Models.ResultsEnum.notInserted) { TempData["errorMsg"] = LangText.checkConnection; return(View()); } else if (checkInserted == BusinessObjects.Models.ResultsEnum.inserted) { return(RedirectToAction("Home", "Branches")); } else { ViewBag.errorMsg = LangText.somethingWentWrongAlert; return(RedirectToAction("Home", "Branches")); } } else { return(View()); } } catch (Exception ex) { ExceptionsWriter.saveEventsAndExceptions(ex, "Exceptions not handled", EventLogEntryType.Error); return(View("Error")); } }