internal void UserLoggedOut()
        {
            ActiveUser activeUser = ActiveUser.GetActiveUser();

            if (activeUser != null)
            {
                activeUser.ClearInSession();
            }
        }
Beispiel #2
0
        public ActionResult Details(int id)
        {
            ProductService productService = GeneralService.GetProductService();
            ActiveUser     user           = ActiveUser.GetActiveUser();

            if (user.IsAuthenticated)
            {
                var transaction = productService.GetLeadingOffer(id);
                if (transaction == null)
                {
                    ViewBag.Message = "There are no offers yet!";
                }
                else
                {
                    ViewBag.Message = (transaction.CustomerID == user.CustomerId) ? "You are leading this offer!" : "You are not leading!";
                }
            }
            return(View(productService.Get(id)));
        }
Beispiel #3
0
        public ActionResult MakeOffer(int id, string offerPrice, long?customerId)
        {
            string message = string.Empty, newPrice = offerPrice;
            bool   result = true;

            try
            {
                if ((customerId ?? 0) == 0)
                {
                    customerId = ActiveUser.GetActiveUser().CustomerId;
                }

                if (!customerId.HasValue || customerId.Value == 0)
                {
                    throw new Exception("You are not authorized to submit an offer.");
                }

                ProductService productService = GeneralService.GetProductService();
                Decimal        price          = 0;
                if (Decimal.TryParse(offerPrice, out price))
                {
                    productService.CreateOffer(id, price, customerId.Value);
                    message  = string.Format("Offer for ${0:2} submitted.", offerPrice);
                    newPrice = price.ToString("C");
                }
                else
                {
                    message = string.Format("Offer price ${0} is invalid.", offerPrice);
                }
            }
            catch (Exception ex)
            {
                message = string.Format("Error submitting the offer; {0}", ex.Message);
                result  = false;
            }

            return(Json(new { result = result, message = message, newPrice = newPrice }));
            //return RedirectToAction("Details", new { id = id });
        }