public ActionResult Create([Bind(Include = "ID,Comment,Point,CoffeeCommentDate,CoffeeID,UserID")] CoffeeComment coffeeComment) { Customer customer = Session["OnlineKullanici"] as Customer; if (customer == null) { return(Redirect("/Login/Login")); } else if (customer.AuthorizationID == 1 || customer.AuthorizationID == 2) { if (ModelState.IsValid) { _coffeeCommentConcrete._coffeeCommentRepository.Insert(coffeeComment); _coffeeCommentConcrete._coffeeCommentUnitOfWork.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.CoffeeID = new SelectList(_coffeeConcrete._coffeeRepository.GetEntity(), "ID", "CoffeeName"); ViewBag.UserID = new SelectList(_customerConcrete._customerRepository.GetEntity(), "ID", "UserName"); return(View(coffeeComment)); } else { return(Redirect("/Coffee/Coffees")); } }
public ActionResult GiveRate(int id, FormCollection frm) { if (Session["OnlineKullanici"] == null) { return(RedirectToAction("Login", "Login")); } OrderDetail orderDetail = _orderDetailConcrete._orderDetailRepository.GetById(id); int baristaId = orderDetail.BaristaID; int coffeeId = orderDetail.CoffeeID; BaristaComment baristaComment = new BaristaComment() { BaristaID = baristaId, CustomerID = (Session["OnlineKullanici"] as Customer).ID, Point = Convert.ToByte(frm["brating"]), BaristaCommentDate = DateTime.Now }; _baristaCommentConcrete._baristaCommentRepository.Insert(baristaComment); _baristaCommentConcrete._baristaCommentUnitOfWork.SaveChanges(); CoffeeComment coffeeComment = new CoffeeComment() { CustomerID = (Session["OnlineKullanici"] as Customer).ID, CoffeeID = coffeeId, Point = Convert.ToByte(frm["crating"]), CoffeeCommentDate = DateTime.Now }; _coffeeCommentConcrete._coffeeCommentRepository.Insert(coffeeComment); _coffeeCommentConcrete._coffeeCommentUnitOfWork.SaveChanges(); Barista barista = _baristaConcrete._baristaRepository.GetById(baristaId); Coffee coffee = _coffeeConcrete._coffeeRepository.GetById(coffeeId); barista.AVGPoint = _baristaCommentConcrete.CalculateBaristaAVGPoint(); coffee.AVGPoint = _coffeeCommentConcrete.CalculateCoffeeAVGPoint(); _coffeeConcrete._coffeeUnitOfWork.SaveChanges(); _baristaConcrete._baristaUnitOfWork.SaveChanges(); orderDetail.IsRated = true; _orderDetailConcrete._orderDetailUnitOfWork.SaveChanges(); _baristaConcrete._baristaUnitOfWork.Dispose(); return(Redirect(Request.UrlReferrer.ToString())); }
public ActionResult AddReview(int id, FormCollection frm) { CoffeeComment coffeeComment = new CoffeeComment() { CoffeeID = id, Comment = frm["review"], CustomerID = (Session["OnlineKullanici"] as Customer).ID, CoffeeCommentDate = DateTime.Now }; _coffeeCommentConcrete._coffeeCommentRepository.Insert(coffeeComment); _coffeeCommentConcrete._coffeeCommentUnitOfWork.SaveChanges(); _coffeeCommentConcrete._coffeeCommentUnitOfWork.Dispose(); return(Redirect(Request.UrlReferrer.ToString())); }
// GET: Admin/CoffeeComments/Details/5 public ActionResult Details(int id) { Customer customer = Session["OnlineKullanici"] as Customer; if (customer == null) { return(Redirect("/Login/Login")); } else if (customer.AuthorizationID == 1 || customer.AuthorizationID == 2) { CoffeeComment coffeeComment = _coffeeCommentConcrete._coffeeCommentRepository.GetById(id); return(View(coffeeComment)); } else { return(Redirect("/Coffee/Coffees")); } }
public ActionResult DeleteConfirmed(int id) { Customer customer = Session["OnlineKullanici"] as Customer; if (customer == null) { return(Redirect("/Login/Login")); } else if (customer.AuthorizationID == 1 || customer.AuthorizationID == 2) { CoffeeComment coffeeComment = _coffeeCommentConcrete._coffeeCommentRepository.GetById(id); _coffeeCommentConcrete._coffeeCommentRepository.Delete(coffeeComment); _coffeeCommentConcrete._coffeeCommentUnitOfWork.SaveChanges(); return(RedirectToAction("Index")); } else { return(Redirect("/Coffee/Coffees")); } }
// GET: Admin/CoffeeComments/Edit/5 public ActionResult Edit(int id) { Customer customer = Session["OnlineKullanici"] as Customer; if (customer == null) { return(Redirect("/Login/Login")); } else if (customer.AuthorizationID == 1 || customer.AuthorizationID == 2) { CoffeeComment coffeeComment = _coffeeCommentConcrete._coffeeCommentRepository.GetById(id); ViewBag.CoffeeID = new SelectList(_coffeeConcrete._coffeeRepository.GetEntity(), "ID", "CoffeeName", coffeeComment.CoffeeID); ViewBag.UserID = new SelectList(_customerConcrete._customerRepository.GetEntity(), "ID", "UserName", coffeeComment.CustomerID); return(View(coffeeComment)); } else { return(Redirect("/Coffee/Coffees")); } }