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(WorkVM user)
        {
            WorkBL newUser = AutoMapperBL <WorkVM, WorkBL> .Map(user);

            workBL.Update(newUser);
            return(RedirectToActionPermanent("Index", "Works"));
        }
Ejemplo n.º 3
0
        public void Update(WorkBL work)
        {
            if (null == work)
            {
                return;
            }

            var item = AutoMapperBL <WorkBL, Work> .Map(work);

            Dbcontext.UowRepositoryWorks.Update(item);
            Dbcontext.Save();
        }
Ejemplo n.º 4
0
        public void Create(WorkBL work)
        {
            if (null == work)
            {
                return;
            }

            var item = new Work()
            {
                Title = work.Title, DateOfPublication = work.DateOfPublication, Content = work.Content, GenreId = work.GenreId, UserId = work.UserId
            };

            Dbcontext.UowRepositoryWorks.Create(item);
            Dbcontext.Save();
        }
        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"));
        }