public ActionResult DisplayAllStarters() { //int accTypeId = 2; //var accounts = db.Accounts.Include(a => a.AccountType); //List<Account> StarterList = new List<Account>(); //foreach(Account ac in accounts) //{ // if(ac.AccountType_Id == accTypeId) // { // StarterList.Add(ac); // } //} //return View(StarterList); int accTypeId = 2; var accounts = db.Accounts.Include(a => a.AccountType); var userAccounts = (from ac in db.Accounts where ac.AccountType_Id == 2 select ac).First(); //var result = db.Accounts.Where(model => model.AccountType_Id.Equals(Account.Email) // && model.Password.Equals(Account.Password)).FirstOrDefault(); //var userAccounts2 = db.Accounts.Where(Account => Account.AccountType_Id == 2) // .Select Account); List< AccountProjectVM > StarterList = new List<AccountProjectVM>(); foreach (Account ac in accounts) { if (ac.AccountType_Id == accTypeId) { AccountProjectVM APVM = new AccountProjectVM(); APVM.Account = ac; foreach (Project p in db.Projects) { if (p.AccountId == ac.Id) { APVM.RelatedProjects.Add(new ProjectDBModel.RelatedProjects() { Id = p.Id, PName = p.PName, PSubHeading = p.PSubHeading, PInfo = p.PInfo, PLogo = p.PLogo, ReqInvestment = p.ReqInvestment, PRatings = p.PRatings, PStartDate = p.PStartDate, PEndDate = p.PEndDate, AccountId = p.AccountId }); } } StarterList.Add(APVM); } } return View(StarterList); // return PartialView("~/Views/Projects/_RelatedProjects.cshtml", APVM); }
public ActionResult RelatedProjects2() { string id = "25"; if (id == null) { return new HttpStatusCodeResult(HttpStatusCode.BadGateway); } Account account = db.Accounts.Find(Convert.ToInt32(id)); if (account == null) { return HttpNotFound(); } AccountProjectVM APVM = new AccountProjectVM(); APVM.Account = account; foreach (Project p in db.Projects) { if (p.AccountId == Convert.ToInt32(id)) { APVM.RelatedProjects.Add(new ProjectDBModel.RelatedProjects() { Id = p.Id, PName = p.PName, PSubHeading = p.PSubHeading, PInfo = p.PInfo, PLogo = p.PLogo, ReqInvestment = p.ReqInvestment, PRatings = p.PRatings, PStartDate = p.PStartDate, PEndDate = p.PEndDate, AccountId = p.AccountId }); } } return PartialView("~/Views/Projects/_RelatedProjects.cshtml", APVM); }