public string GetImageUrl(int id)
        {
            var  imgUrl = new DataAccess().IndexImageExits(id, "Lots")
                    ? @"Content/Image/Lots/" + id.ToString() + @"/index.jpg"
                    : @"Content/Image/Lots/Default/index.jpg";

            return imgUrl;
        }
 public ActionResult SearchBySubCategory(int id)
 {
     var data = new DataAccess();
     var model = new IndexModel()
     {
         Lots = data.SearchLotBySubCategoryId(id)
     };
     return View("Index", model);
 }
 public ActionResult Index(IndexModel model = null)
 {
     var dataAccess = new DataAccess();
     if (!String.IsNullOrWhiteSpace(model.SearchQuery))
         return View(new IndexModel()
         {
             Lots = dataAccess.SearchLotByName(model.SearchQuery)
         });
     if (model.Lots == null )
     {
         return View(new IndexModel()
         {
             Lots = dataAccess.GetConvertedActualLotCollection().OrderBy(t =>t.ActualDate)
         });
     }
     else
     {
         return View(model);
     }
 }
 public LotTypePreviewModel(string typeName)
 {
     TypeName = typeName;
     LotTypePreviewCollection = new DataAccess().GetLotTypePreviewCollection(typeName);
 }
        public ActionResult Register(RegisterModel model)
        {
            if (ModelState.IsValid)
            {
                var createStatus = new DataAccess().AddNewUser(model);
                if (createStatus == MembershipCreateStatus.Success)
                {
                    FormsAuthentication.SetAuthCookie(model.UserName,false);
                    return RedirectToAction("Index", "Home");
                }
                ModelState.AddModelError("", ErrorCodeToString(createStatus));
            }

            // если мы оказались тут, чтото пошло не так, заново отобразить форму
            return View(model);
        }
 public HotCatalogModel()
 {
     Lots = new DataAccess().GetHotLots();
 }
 public ActionResult AddToBookmarks(LotInfo lotInfo)
 {
     var lotid = Convert.ToInt32(Request.Cookies["LotId"].Value);
     var message = new DataAccess().AddToBookmarks(lotid, HttpContext.User.Identity.Name);
     return RedirectToAction("Index", new { id = lotid, @errormsg = message });
 }
 public ActionResult RestoreLot(LotInfo lotInfo)
 {
     var lotid = Convert.ToInt32(Request.Cookies["LotId"].Value);
     var message = new DataAccess().RestoreLot(lotid);
     return RedirectToAction("Index", new { id = lotid, @errormsg=message });
 }
        public ActionResult MakeBet(LotViewModel model)
        {
            var lotid = Convert.ToInt32(Request.Cookies["LotId"].Value); //TODO:убрать этот костыль
            var message = "";
            if (ModelState.IsValid)
            {
                message = new DataAccess().MakeBet(HttpContext.User.Identity.Name,lotid, model.BetValue);
                if (String.IsNullOrWhiteSpace(message))
                {
                    return RedirectToAction("Index", new{id=lotid});
                }
                model = new DataAccess().GetViewModelById(lotid);
                ModelState.AddModelError("", message);

            }

            return RedirectToAction("Index", new { id = lotid, @errormsg = message});
        }
        public ActionResult LeaveComment(CommentInfo model)
        {
            var id = Convert.ToInt32(Request.Cookies["LotId"].Value);
            var message = "";
            if (ModelState.IsValid)
            {
                message = new DataAccess().LeaveComment(id, HttpContext.User.Identity.Name, model.CommentText);
            }

            return RedirectToAction("Index", new { id = id, @errormsg = message });
        }
 public CreateLotModel()
 {
     LotTypeCollection = new DataAccess().GetLotTypeList();
     ActualDate = DateTime.Parse(DateTime.Now.ToShortDateString());
 }
Example #12
0
 public IndexModel()
 {
     Lots =  new DataAccess().ConvertedActualLotCollection;
 }