Esempio n. 1
0
        public ActionResult MakeBet(int id = 0)
        {
            var lot = lotService.GetLot(id);

            if (lot == null)
            {
                return(HttpNotFound());
            }
            var user = userService.GetUserByEmail(User.Identity.Name);

            bool isBetMade = lotService.MakeBet(user.UserId, lot.LotId);

            if (Request.IsAjaxRequest())
            {
                if (isBetMade)
                {
                    var betViewModel = Mapper.Map <BetViewModel>(lot.Bets.Last());

                    return(PartialView("_BetPartial", betViewModel));
                }
                return(Json(new { success = false, }, JsonRequestBehavior.AllowGet));
            }
            else
            {
                if (isBetMade)
                {
                    return(RedirectToAction("Details", new { id = lot.LotId }));
                }
                else
                {
                    return(RedirectToAction("Details", new { id = lot.LotId }));
                }
            }
        }
        public ActionResult <LotDTO> GetLot(int id)
        {
            var lot = _lotService.GetLot(id);

            if (lot == null)
            {
                return(NotFound());
            }
            return(Ok(lot));
        }
Esempio n. 3
0
 public IHttpActionResult Get(int id)
 {
     try
     {
         var lot = lotService.GetLot(id);
         return(Ok(Mapper.Map <LotDTO, LotModel>(lot)));
     }
     catch (NotFoundException)
     {
         return(NotFound());
     }
 }