Example #1
0
        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());
        }
Example #2
0
        public void Update(WorksBO work)
        {
            Works newWork = AutoMapper <WorksBO, Works> .Map(work);

            Database.WorksUowRepository.Update(newWork);
            Database.Save();
        }
Example #3
0
        public ActionResult Update(WorksViewModel user)
        {
            WorksBO newUser = AutoMapper <WorksViewModel, WorksBO> .Map(user);

            workServ.Update(newUser);
            return(RedirectToActionPermanent("Index", "Works"));
        }
Example #4
0
        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();
        }
Example #5
0
        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"));
        }