public Tenant AddTenant() { var tenant = new Faker <Tenant>().StrictMode(true) .RuleFor(t => t.Id, Guid.NewGuid()) .RuleFor(t => t.IsActive, true) .RuleFor(t => t.License, "Standard") .RuleFor(t => t.Name, t => t.Random.String2(10, 10)) .RuleFor(t => t.OrganizationName, t => t.Company.CompanyName()) .Generate(); return(_tenantRepository.AddTenant(tenant)); }
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()); } }