public ActionResult Create(WorksViewModel model) { HttpCookie cookieReq = Request.Cookies["My localhost cookie"]; int ids = 0; if (cookieReq != null) { ids = Convert.ToInt32(cookieReq["ids"]); } else { FormsAuthentication.SignOut(); return(RedirectToActionPermanent("Index", "Works")); } model.UserId = ids; model.DateOfPublication = DateTime.Now; if (ModelState.IsValid) { WorksBO newWork = AutoMapper <WorksViewModel, WorksBO> .Map(model); workServ.Create(newWork); return(RedirectToActionPermanent("Index", "Works")); } return(View()); }
public void Update(WorksBO work) { Works newWork = AutoMapper <WorksBO, Works> .Map(work); Database.WorksUowRepository.Update(newWork); Database.Save(); }
public ActionResult Update(WorksViewModel user) { WorksBO newUser = AutoMapper <WorksViewModel, WorksBO> .Map(user); workServ.Update(newUser); return(RedirectToActionPermanent("Index", "Works")); }
public void Create(WorksBO work) { Works newWork = new Works() { Name = work.Name, DateOfPublication = work.DateOfPublication.Date, Content = work.Content, GenreId = work.GenreId, UserId = work.UserId }; Database.WorksUowRepository.Create(newWork); Database.Save(); }
public ActionResult Details(WorksViewModel user) { HttpCookie cookieReq = Request.Cookies["My localhost cookie"]; int ids = 0; if (cookieReq != null) { ids = Convert.ToInt32(cookieReq["ids"]); } WorksBO newUser = AutoMapper <WorksViewModel, WorksBO> .Map(user); CommentsBO newComment = new CommentsBO(); newComment.Comment = newUser.Name; newComment.WorkId = newUser.Id; newComment.UserId = ids; return(RedirectToActionPermanent("Index", "Works")); }