public ActionResult Review(string id, string name, string review, string inlineRadioOptions) { try { HttpRequest cookie = serviceProvider.GetRequiredService <IHttpContextAccessor>()?.HttpContext.Request; string token = cookie.Cookies[SecurityManager._securityToken]; string customerId = SecurityManager.getUserId(token); ProductReview productReview = new ProductReview() { Id = Guid.NewGuid().ToString(), Name = name, Review = review, ProductId = id, Star = Convert.ToInt32(inlineRadioOptions), CustomerId = customerId, CreateAt = DateTime.UtcNow }; productReViewRepository.Add(productReview); productReViewRepository.Save(); return(View()); } catch (Exception) { throw; } }
public bool DeleteReview(string id) { try { var productRv = productReViewRepository.All.Where(p => p.Id == id).FirstOrDefault(); productReViewRepository.Delete(productRv); productReViewRepository.Save(); return(true); } catch (Exception) { return(false); throw; } }