public ActionResult BranchLogoLoader(int id) { Branches oldclient = BranchModels.GetBranchById(id); if (oldclient != null && oldclient.Logo != null) { var q = oldclient.Logo; byte[] cover = q; // byte[] studentPhoto = StudentModels.GetStudentPhoto(id); if (cover != null) { return(File(cover, "image/jpg")); } } return(null); }
// // GET: /Branch/Delete/5 public ActionResult Close(int id) { if (Session["ClientId"] != null) { ViewData["Zones"] = Utilities.GetZoneNameList((int)Session["ClientId"]); if (Session["ZoneId"] != null) { ViewData["Regions"] = Utilities.GetRegionNameList((int)Session["ClientId"], (int)Session["ZoneId"]); } else { ViewData["Regions"] = Utilities.GetRegionNameList((int)Session["ClientId"], null); } if (Roles.IsUserInRole("CenterManager")) { if (Session["BranchId"] != null) { ViewData.Model = BranchModels.GetBranchById((int)Session["BranchId"]); } else { ViewData.Model = null; } } else { List <vw_Branches> brList = new List <vw_Branches>(); brList = BranchModels.GetBranchesList((int)Session["ClientId"]); if (brList.Any(bl => bl.Id == id)) { ViewData.Model = BranchModels.GetBranchById((int)id); } else { ViewData.Model = null; } } } ViewData["BranchTypes"] = Utilities.GetBranchTypeList(); ViewData["States"] = Utilities.GetStateList(Utilities.IndiaCountryCode); ViewData["Countries"] = Utilities.GetCountryList(); return(View()); }
public ActionResult Close(int id, FormCollection collection, Branches br, HttpPostedFileBase agentPhoto) { ViewData["BranchTypes"] = Utilities.GetBranchTypeList(); ViewData["States"] = Utilities.GetStateList(Utilities.IndiaCountryCode); ViewData["Countries"] = Utilities.GetCountryList(); if (Roles.IsUserInRole("SuperAdmin")) { ViewData["Clients"] = ClientModels.GetClientNameList(); } if (Session["ClientId"] != null) { br.ClientId = (int)Session["ClientId"]; ViewData["Zones"] = Utilities.GetZoneNameList((int)Session["ClientId"]); if (Session["ZoneId"] != null) { ViewData["Regions"] = Utilities.GetRegionNameList((int)Session["ClientId"], (int)Session["ZoneId"]); } else { ViewData["Regions"] = Utilities.GetRegionNameList((int)Session["ClientId"], null); } List <vw_Branches> brList = new List <vw_Branches>(); brList = BranchModels.GetBranchesList((int)Session["ClientId"]); if (brList.Any(bl => bl.Id == id)) { ViewData.Model = BranchModels.GetBranchById((int)id); } } if (!ModelState.IsValid) { //ModelState.AddModelError("error", "Employee Id already exists"); ApplicationMessages msg = new ApplicationMessages("Invalid entry.", MessageType.Error); ViewData["Message"] = msg; return(View()); } //if (agentPhoto != null) //{ // if (agentPhoto.ContentLength > 0) // { // Int32 length = agentPhoto.ContentLength; // byte[] tempImage = new byte[length]; // agentPhoto.InputStream.Read(tempImage, 0, length); // br.Logo = tempImage;// file.InputStream; // br.ContentType = agentPhoto.ContentType; // } //} int result = BranchModels.CloseBranch(br); if (result > 0) { ApplicationMessages msg = new ApplicationMessages("Branch closed successfully.", MessageType.Success); ViewData["Message"] = msg; } else if (result == -1) { ApplicationMessages msg = new ApplicationMessages("Failed to close Branch. Please try again.", MessageType.Error); ViewData["Message"] = msg; } else { ApplicationMessages msg = new ApplicationMessages("Failed to close Branch. Please try again.", MessageType.Faild); ViewData["Message"] = msg; } return(View()); }