Exemplo n.º 1
0
        public ActionResult BidExpired(FormCollection collection)
        {
            if (!authController.IsUserLoggedIn(Request, Response))
            {
                return(Redirect("~/Auth/Login"));
            }
            var productId = int.Parse(collection["product-id"]);
            var product   = productServiceClient.GetProductById(productId);

            if (!(DateTime.Now >= product.EndDate))
            {
                ViewBag.user = authController.GetUserIdByCookie(Request.Cookies["auth"]);
                return(Redirect("~/Products"));
            }
            try
            {
                ViewBag.user = authController.GetUserLoggedUser(Request);
                new BidServiceReference.BidServiceClient().BidExpired(product.Id);
                return(Redirect("~/Products"));
            }
            catch (Exception e)
            {
                ViewBag.massError = e.Message;
                ViewBag.products  = GetAvailableProductsWithBidPrice();
                return(View("Catalog"));
            }
        }
        public ActionResult PurchaseCoins(FormCollection form)
        {
            if (!authController.IsUserLoggedIn(Request, Response))
            {
                return(Redirect("~/auth/login"));
            }
            int coins      = int.Parse(form["coins"]);
            var userClient = new UserServiceReference.UserServiceClient();

            if (coins <= 0)
            {
                return(RedirectToAction("Edit"));
            }
            var currentUser = authController.GetUserLoggedUser(Request);

            currentUser.Coins += coins;

            try
            {
                userClient.UpdateUser(currentUser);
            }
            catch (Exception)
            {
                @ViewBag.coinsPurchaseError = "pesho";
            }

            return(RedirectToAction("Edit"));
        }
 public ActionResult Index()
 {
     if (authController.IsUserLoggedIn(Request, Response))
     {
         ViewBag.user   = authController.GetUserLoggedUser(Request);
         ViewBag.userId = new AuthController().GetUserIdByCookie(Request.Cookies["auth"]);
         return(View("Index"));
     }
     return(Redirect("~/Auth/Login"));
 }