public UserVM(User row) { UserId = row.UserId; RoleId = row.RoleId; FirstName = row.FirstName; LastName = row.LastName; Email = row.Email; Description = row.Description; Password = row.Password; Active = row.Active; LinkedIn = row.LinkedIn; StackOverflow = row.StackOverflow; DateOfBirth = row.DateOfBirth; EducationLevel = row.EducationLevel; Title = row.Title; AverageGrade = row.AverageGrade; IsCompleted = row.IsCompleted; Salary = HelpClass.ReturnSalary(UserId); Jobs = HelpClass.ReturnJobs(UserId); Blocked = row.Blocked; IsRegistered = row.IsRegistered; MadeUp = row.MadeUp; }
public ActionResult PublicProfile(int id) { if (id < 100) { return(HttpNotFound()); } UserVM model = null; try { using (ITExpertsContext db = new ITExpertsContext()) { model = new UserVM(db.Users.Find(id)); List <WorkingAt> jobs = db.WorkingAts.Where(x => x.UserId == id).ToList(); int index = 0; if (jobs.Count() != 0) { model.Jobs = new WorkingAtVM[db.WorkingAts.Where(x => x.UserId == model.UserId).GroupBy(x => new { x.CompanyName, x.Since }).Select(x => x).Count()]; int i = 0; while (i < jobs.Count) { WorkingAtVM job = new WorkingAtVM(); job.CompanyId = jobs[i].CompanyId; job.CompanyName = jobs[i].CompanyName; job.Description = jobs[i].Description; job.JobId = jobs[i].JobId; job.PathId = jobs[i].Tech.PathId; job.Since = jobs[i].Since; job.Until = jobs[i].Until; job.UserId = id; job.TechId = new int[db.WorkingAts.Count(x => x.UserId == id && x.CompanyId == job.CompanyId && x.Since == job.Since)]; job.Technology = new string[db.WorkingAts.Count(x => x.UserId == id && x.CompanyId == job.CompanyId && x.Since == job.Since)]; int j = 0; while (j < job.TechId.Count()) { job.TechId[j] = jobs[i].TechId; Technology bla = db.Technologies.Find(jobs[i].TechId); job.Technology[j] = bla.TechName; i++; j++; } model.Jobs[index] = job; index++; } } model.Salary = HelpClass.ReturnSalary(model.UserId); } } catch (Exception) { } if (model != null) { return(View(model)); } return(HttpNotFound()); }