public ActionResult GetWorks(string filter = null) { var workList = workServ.GetWorks().Join(userServ.GetUsers(), w => w.UserId, u => u.Id, (w, u) => new { Id = w.Id, Name = w.Name, DateOfPublication = w.DateOfPublication, Content = w.Content, IsDelete = u.IsDelete, Username = u.Login, GenreId = w.GenreId }).Join(genreServ.GetGenres(), w => w.GenreId, g => g.Id, (w, g) => new InfoModel { Id = w.Id, Name = w.Name, DateOfPublication = w.DateOfPublication.Date, Content = w.Content, UserName = w.Username, GenreName = g.Name, IsDelete = w.IsDelete }).ToList(); foreach (var item in workList) { if (item.IsDelete == true) { item.UserName = "******"; } } ViewBag.WorksList = filter == null ? workList : workList.Where(x => x.Name.Contains(filter) || x.GenreName.Contains(filter) || x.UserName.Contains(filter)); return(View("_WorksTable", filter == null ? AutoMapper <IEnumerable <WorksBO>, List <WorksViewModel> > .Map(workServ.GetWorks()) : AutoMapper <IEnumerable <WorksBO>, List <WorksViewModel> > .Map(workServ.GetWorks().Where(x => x.Name.Contains(filter)).ToList()))); }
public ActionResult PersonalProfile() { HttpCookie cookieReq = Request.Cookies["My localhost cookie"]; int ids = 0; if (cookieReq != null) { ids = Convert.ToInt32(cookieReq["ids"]); } UsersViewModel oldUser = AutoMapper <UsersBO, UsersViewModel> .Map(userServ.GetUser, (int)ids); ViewBag.UserWorksList = workServ.GetWorks().Where(x => x.UserId == ids).ToList(); return(View(oldUser)); }