private async Task <CommentRatingDTO> GetCommentRatingDTOFromModel(CommentRatingModel rating, string userId, string commentId) { UserDTO user = await _userService.GetUserById(userId); return(new CommentRatingDTO { CommentId = commentId, ApplicationUserId = userId, GivenRating = rating.givenRating }); }
public ActionResult CommentRating(Guid commentId, Guid storeItemId) { CommentRatingModel model = new CommentRatingModel() { Id = Guid.NewGuid(), CommentId = commentId, StoreItemId = storeItemId, }; return(View(model)); }
public static void UpdateCommentRating(CommentRatingModel model) { UnitOfWorkRepository unitOfWork = new UnitOfWorkRepository(); if (model == null) { return; } var commentRating = ConvertToCommentRating(model); unitOfWork.CommentRatingRepository.Update(commentRating); }
public static void AddCommentRating(CommentRatingModel model) { var commentRating = ConvertToCommentRating(model); if (commentRating == null) { return; } UnitOfWorkRepository unitOfWork = new UnitOfWorkRepository(); unitOfWork.UserCommentRepository.AddCommentRating(commentRating); }
public async Task <IActionResult> CreateCommentRating([Required] string id, [FromBody] CommentRatingModel item) { if (ModelState.IsValid && User.Identity.IsAuthenticated) { ApplicationUser user = await _authenticationManager.UserManager.FindByNameAsync(User.Identity.Name); CommentRatingDTO commentRating = await GetCommentRatingDTOFromModel(item, user.Id, id); commentRating = await _commentRatingService.Create(commentRating); return(Ok(await GetCommentRatingModelFromDTO(commentRating))); } return(BadRequest(ModelState)); }
public ActionResult CommentRating(CommentRatingModel model) { string identity = User.Identity.Name; Guid userId = Guid.Parse(identity); if (model == null) { return(View(model)); } model.OwnerId = userId; model.Id = Guid.NewGuid(); model.DataCreated = DateTime.Now; CommentProcessor.AddCommentRating(model); return(RedirectToAction("Details", "Products", new { id = model.StoreItemId })); }
public static CommentRating ConvertToCommentRating(CommentRatingModel model) { if (model == null) { return(null); } CommentRating commentRating = new CommentRating() { Id = model.Id, CommentId = model.CommentId, OwnerId = model.OwnerId, storeItemId = model.StoreItemId, DataCreated = model.DataCreated, Rating = model.Rating, DownVote = model.DownVote, UpVote = model.UpVote, Reported = model.Report, ReportText = model.OpinionText, }; return(commentRating); }
public static CommentRatingModel ConvertToCommentRatingModel(CommentRating commentRating) { if (commentRating == null) { return(null); } CommentRatingModel model = new CommentRatingModel() { Id = commentRating.Id, CommentId = commentRating.CommentId, OwnerId = commentRating.OwnerId, StoreItemId = commentRating.storeItemId, DataCreated = commentRating.DataCreated, Rating = commentRating.Rating, DownVote = commentRating.DownVote, UpVote = commentRating.UpVote, Report = commentRating.Reported, OpinionText = commentRating.ReportText, }; return(model); }
public ActionResult EditCommentRating(CommentRatingModel model) { CommentProcessor.UpdateCommentRating(model); return(RedirectToAction("Details", "Products", new { id = model.StoreItemId })); }