public ActionResult AddTenant(TblTenant objTenant, HttpPostedFileBase file) { try { if (ModelState.IsValid) { if (objTenant.TenantId == 0) { var result = tr.GetTenantByName(objTenant.TenantName); if (!result) { TempData["Message"] = "Tenant Already Exist"; return(View(objTenant)); } } if (file != null) { var logoURL = System.Configuration.ConfigurationManager.AppSettings["LogoURL"]; var logoPhysicalURL = System.Configuration.ConfigurationManager.AppSettings["logoPhysicalURL"]; string filePhysicalPath = System.IO.Path.Combine(logoPhysicalURL + "\\" + objTenant.TenantName + ".jpg"); string path = System.IO.Path.Combine(logoURL + "\\" + objTenant.TenantName + ".jpg"); file.SaveAs(filePhysicalPath); objTenant.Logo = path; } int rows = 0; if (objTenant.TenantId == 0) { rows = tr.AddTenant(objTenant); } else { rows = tr.EditTenants(objTenant); } if (rows != 0) { return(RedirectToAction("AddTenantUser", new { @id = objTenant.TenantId })); } else { return(View(objTenant)); } } return(View(objTenant)); } catch (Exception ex) { newException.AddException(ex); return(View()); } }