public ActionResult Create(BidViewModel bid)
 {
     if(UserViewModel==null)
         return new HttpStatusCodeResult(401);
     if(UserViewModel.Banned)
         return new HttpStatusCodeResult(403);
     var ajaxRequest = Request.IsAjaxRequest();
     if (ModelState.IsValid)
     {
         
         if (!ajaxRequest)
             bid.LotId = bid.Id;
         var lot = _lotService.GetLotEntity(bid.LotId);
         if (lot == null)
         {
             if (ajaxRequest)
                 return new HttpStatusCodeResult(404, "Something went wrong with your request. Please try again later.");
             return new HttpStatusCodeResult(404);
         }
         if ((lot.LotClosed) || (lot.LotEnded))
         {
             if (ajaxRequest)
                 return new HttpStatusCodeResult(422, "You can't place bids on closed or ended lot");
             ModelState.AddModelError(string.Empty,"You can't place bids on closed or ended lot");
             return View(bid);
         }
         if (bid.Amount < lot.MinimalBet)
         {
             if (ajaxRequest)
                 return new HttpStatusCodeResult(422, "Your bid's amount can't be less than Minimal Bid Amount (starting bid)");
             ModelState.AddModelError(string.Empty, "Your bid's amount can't be less than Minimal Bid Amount (starting bid)");
             return View(bid);
         }
         bid.Placed=DateTime.Now;
         bid.UserId = UserViewModel.Id;
         var bidEntity = bid.ToBidEntity();
         try
         {
             _bidService.AddBid(bidEntity);
         }
         catch (BllBidTooLowException)
         {
             if(ajaxRequest)
                 return new HttpStatusCodeResult(422, "Your bid's amount too low. (There is already a bid with higher amount)");
             ModelState.AddModelError(string.Empty, "Your bid's amount too low. (There is already a bid with higher amount)");
             return View(bid);
         }
         if(ajaxRequest)
             return Content("");
         return RedirectToAction("Details", "Lot", new { id = lot.Id });
     }
     if (ajaxRequest)
         return new HttpStatusCodeResult(422, "Incorrect data!");
     return View(bid);
 }
 public ActionResult Create(int? id)
 {
     if(UserViewModel==null)
         return new HttpStatusCodeResult(401);
     if(id==null)
         return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
     var lot = _lotService.GetLotEntity(id.Value);
     if (lot.CreatedByUserId == UserViewModel.Id)
     {
         TempData["error"] = "You cannot bid on you own lots!";
         return RedirectToAction("Details","Lot",new {id=lot.Id});
     }
     var vm = new BidViewModel
     {
         LotId = lot.Id,
         Lot = lot.ToLotViewModel()
     };
     return View(vm);
 }