Hi,
I want to remove static keyword from below method and some one help me ,if i remove what are all changes i need to do.
Helperclass.cs
public static SelectList CompaniesByUser(int customerId, User user, bool addBlankOption = false)
{
DbContextScopeFactory DbContext = new DbContextScopeFactory(new Redi2ContextFactory(new LoginSecurityRepo().GetRMApplConnection()));
AmbientDbContextLocator ambientContextLocator = new AmbientDbContextLocator();
var repo = new CompanyRepository(ambientContextLocator);
using (var ctx = DbContext.CreateReadOnly())
{
var companies = repo.GetCompaniesByUser(user, customerId);
if (addBlankOption)
companies.Insert(0, new Organization { Id = 0, Name = "
return new SelectList(companies.Select(c => new { c.Id, Name = string.IsNullOrEmpty(c.OrganizationNumber) ? c.Name : $"{c.Name} | {c.OrganizationNumber}" }), "Id", "Name");
}
}
Controller
SelectList companyList = SelectListItemHelper.CompaniesByUser(customerId,user,true);
BillingViewModel model = new BillingViewModel()
{
Companies = SelectListItemHelper.CompaniesByUser(customerId,user,true),
};
return View(model);

Praveen KumarPosted Jun 9, 2020, 11:29 PM
Jignesh KumarPosted Jun 9, 2020, 10:26 PM