public ActionResult PersonalProfile(UserVM user) { var item = AutoMapperBL <UserVM, UserBL> .Map(user); _userBL.Update(item); return(RedirectToActionPermanent("PersonalProfile", "Users")); }
public ActionResult Create(WorkVM model) { HttpCookie cookieReq = Request.Cookies["Localhost cookie"]; int ids; if (null != cookieReq) { ids = Convert.ToInt32(cookieReq["ids"]); } else { FormsAuthentication.SignOut(); return(RedirectToActionPermanent("Index", "Works")); } model.UserId = ids; model.DateOfPublication = DateTime.Now; if (ModelState.IsValid) { WorkBL newWork = AutoMapperBL <WorkVM, WorkBL> .Map(model); workBL.Create(newWork); return(RedirectToActionPermanent("Index", "Works")); } return(View()); }
public ActionResult Update(int id) { ViewBag.GenreList = new SelectList(genreBL.GetGenres().ToList(), "Id", "Name"); WorkVM work = AutoMapperBL <WorkBL, WorkVM> .Map(workBL.GetWork, id); return(View(work)); }
public ActionResult Update(WorkVM user) { WorkBL newUser = AutoMapperBL <WorkVM, WorkBL> .Map(user); workBL.Update(newUser); return(RedirectToActionPermanent("Index", "Works")); }
public ActionResult Details(int id) { WorkVM work = AutoMapperBL <WorkBL, WorkVM> .Map(workBL.GetWork, id); work.Name = ""; work.UserId = 1; return(View(work)); }
public ActionResult PersonalProfile() { HttpCookie cookieReq = Request.Cookies["Localhost cookie"]; int ids = 0; if (cookieReq != null) { ids = Convert.ToInt32(cookieReq["ids"]); } var item = AutoMapperBL <UserBL, UserVM> .Map(_userBL.GetUser, ids); ViewBag.UserWorksList = _workBL.GetWorks().Where(x => x.UserId == ids).ToList(); return(View(item)); }
public ActionResult Create(UserVM user) { if (ModelState.IsValid) { var item = AutoMapperBL <UserVM, UserBL> .Map(user); item.IsDelete = false; HttpCookie cookie = new HttpCookie("Localhost cookie"); cookie["ids"] = _authentificationBL.GetUserId(user.Login, user.Password).ToString(); cookie.Expires = DateTime.Now.AddHours(1); Response.Cookies.Add(cookie); _userBL.Create(item); return(RedirectToActionPermanent("Index", "Users")); } return(View("Create")); }
public ActionResult DeleteAccount() { HttpCookie cookieReq = Request.Cookies["Localhost cookie"]; int ids = 0; if (cookieReq != null) { ids = Convert.ToInt32(cookieReq["ids"]); } var old = AutoMapperBL <UserBL, UserVM> .Map(_userBL.GetUser, ids); old.IsDelete = true; UserBL @new = AutoMapperBL <UserVM, UserBL> .Map(old); _userBL.Update(@new); FormsAuthentication.SignOut(); return(RedirectToAction("Index", "Home")); }
public ActionResult Details(WorkVM user) { HttpCookie cookieReq = Request.Cookies["Localhost cookie"]; int ids = 0; if (cookieReq != null) { ids = Convert.ToInt32(cookieReq["ids"]); } WorkBL newUser = AutoMapperBL <WorkVM, WorkBL> .Map(user); CommentBL newComment = new CommentBL(); newComment.Comment = newUser.Title; newComment.WorkId = newUser.Id; newComment.UserId = ids; return(RedirectToActionPermanent("Index", "Works")); }
public ActionResult GetWorks(string filter = null) { var workList = workBL.GetWorks().Join(userBL.GetUsers(), w => w.UserId, u => u.Id, (w, u) => new { Id = w.Id, Name = w.Title, DateOfPublication = w.DateOfPublication, Content = w.Content, IsDelete = u.IsDelete, Username = u.Login, GenreId = w.GenreId }).Join(genreBL.GetGenres(), w => w.GenreId, g => g.Id, (w, g) => new UserWithWorkVM { 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 ? AutoMapperBL <IEnumerable <WorkBL>, List <WorkVM> > .Map(workBL.GetWorks()) : AutoMapperBL <IEnumerable <WorkBL>, List <WorkVM> > .Map(workBL.GetWorks().Where(x => x.Title.Contains(filter)).ToList()))); }
public ActionResult Update(int id) { var item = AutoMapperBL <UserBL, UserVM> .Map(_userBL.GetUser, id); return(View(item)); }
public ActionResult Index() { return(View(AutoMapperBL <IEnumerable <UserBL>, List <UserVM> > .Map(_userBL.GetUsers().Where(x => x.IsDelete == false)))); }