public ActionResult Edit([Bind(Include = "ID,Comment,Point,BaristaCommentDate,BaristaID,CustomerID")] BaristaComment baristaComment)
        {
            Customer customer = Session["OnlineKullanici"] as Customer;

            if (customer == null)
            {
                return(Redirect("/Login/Login"));
            }
            else if (customer.AuthorizationID == 1 || customer.AuthorizationID == 2)
            {
                if (ModelState.IsValid)
                {
                    _baristaCommentConrete._baristaCommentRepository.Update(baristaComment);
                    _baristaCommentConrete._baristaCommentUnitOfWork.SaveChanges();
                    return(RedirectToAction("Index"));
                }
                ViewBag.BaristaID  = new SelectList(_baristaConcrete._baristaRepository.GetEntity(), "ID", "Firstname", baristaComment.BaristaID);
                ViewBag.CustomerID = new SelectList(_customerConcrete._customerRepository.GetEntity(), "ID", "FirstName", baristaComment.CustomerID);
                return(View(baristaComment));
            }
            else
            {
                return(Redirect("/Coffee/Coffees"));
            }
        }
Пример #2
0
        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()));
        }
        // GET: Admin/BaristaComment/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)
            {
                BaristaComment baristaComment = _baristaCommentConrete._baristaCommentRepository.GetById(id);
                return(View(baristaComment));
            }
            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)
            {
                BaristaComment baristaComment = _baristaCommentConrete._baristaCommentRepository.GetById(id);
                _baristaCommentConrete._baristaCommentRepository.Delete(baristaComment);
                _baristaCommentConrete._baristaCommentUnitOfWork.SaveChanges();
                return(RedirectToAction("Index"));
            }
            else
            {
                return(Redirect("/Coffee/Coffees"));
            }
        }
        // GET: Admin/BaristaComment/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)
            {
                BaristaComment baristaComment = _baristaCommentConrete._baristaCommentRepository.GetById(id);

                ViewBag.BaristaID  = new SelectList(_baristaConcrete._baristaRepository.GetEntity(), "ID", "Firstname", baristaComment.BaristaID);
                ViewBag.CustomerID = new SelectList(_customerConcrete._customerRepository.GetEntity(), "ID", "FirstName", baristaComment.CustomerID);
                return(View(baristaComment));
            }
            else
            {
                return(Redirect("/Coffee/Coffees"));
            }
        }