TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Praveen Kumar
NA
235
22.1k
How to change to static method to without static ?
Jun 9 2020 8:30 PM
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 = "<select company>" });
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);
Reply
Answers (
2
)
when store the password then face the error?
remove item from cart