Exemple #1
0
        public ActionResult ProductDetails(ProductViewModel model)
        {
            if (ModelState.IsValid)
            {
                var userManager = new UserManager <User>(new UserStore <User>(DbInstance.Instance));
                var user        = userManager.FindByName(User.Identity.Name);
                model.Comment.UserId = user.Id;
                cr.AddOrUpdate(model.Comment);
            }
            var product = pr.SelectById(model.Comment.ProductId);

            model.Product    = product;
            model.commentTab = true;
            return(View(model));
        }
        public ActionResult NewComment(CommentsVM model)
        {
            var identity = User.Identity.Name;
            int?userID   = Userrepo.GetID(identity);

            model.UserID = (int)userID;
            var photomodel = photorepo.ByID(model.PhotoID);

            model.DatePosted = DateTime.Now;


            if (ModelState.IsValid && User.Identity.IsAuthenticated)
            {
                var newComment = ModelMapper.ModelToEntity(model);
                repo.AddOrUpdate(newComment);

                return(RedirectToAction("Details", "Photo", photomodel));
            }
            return(RedirectToAction("Details", "Photo", photomodel));
        }