public JsonResult AutocompleteAllLots(string term) { var lots = _lotService.GetAllLotEntities().Where(l => Regex.IsMatch(l.Name, term, RegexOptions.IgnoreCase)) .Select(l => new { id = l.Id, label = l.Name, value = l.Name }); return(Json(lots.ToList(), JsonRequestBehavior.AllowGet)); }
public ActionResult Categories(int id = 0) { var sectionName = _sectionService.GetSectionEntity(id).SectionName; var categories = _categoryService.GetAllCategoriesBySectionId(id).Select(c => c.ToCategoryDetailsViewModel()).ToList(); ViewBag.SectionId = id; for (int i = 0; i < categories.Count; i++) { var lots = _lotService.GetAllLotEntities() .Where(r => r.CategoryRefId == categories[i].Id); categories[i].UnconfirmedLots = lots.Count(l => !l.IsConfirm); categories[i].TotalLotNumber = _lotService.GetAllLotEntities().Count(l => l.CategoryRefId == categories[i].Id); categories[i].SectionName = sectionName; } return(View(categories.ToList())); }
public ActionResult GetLotsList(string state, string searchString, int?userId, bool isPartial = false) { IEnumerable <LotViewModel> model; if (!String.IsNullOrEmpty(searchString)) { model = _lotService.GetAllLotEntities().Select(l => l.ToMvcLot()).Where(l => Regex.IsMatch(l.Name, searchString, RegexOptions.IgnoreCase)); } else { switch (state) { case ("Sold"): model = _lotService.GetAllLotEntities().Select(l => l.ToMvcLot()).Where(l => l.State == LotStateViewModel.Sold); break; case ("Unsold"): model = _lotService.GetAllLotEntities().Select(l => l.ToMvcLot()).Where(l => l.State == LotStateViewModel.Unsold); break; case ("For sale"): model = _lotService.GetAllLotEntities().Select(l => l.ToMvcLot()).Where(l => l.State == LotStateViewModel.ForSale); break; default: model = _lotService.GetAllLotEntities().Select(l => l.ToMvcLot()); break; } } if (User.IsInRole("User")) { model = model.Where(l => l.UserId == _userService.GetUserByEmail(User.Identity.Name).Id); } else if (userId != null) { model = model.Where(l => l.UserId == userId); } ViewBag.TimeSpan = state; if (isPartial) { return(PartialView("_GetLotsList", model)); } return(View(model)); }
public ActionResult LotRows(string sectionName = null, string categoryName = null) { IList <LotRowViewModel> lots = new List <LotRowViewModel>(); if (categoryName == null) { SectionEntity section = _sectionService.GetAllSectionEntities().FirstOrDefault(s => s.SectionName == sectionName); if (section != null) { foreach (var category in section.Categories) { var lotsTemp = _lotService.GetAllLotEntities() .Where(l => l.CategoryRefId == category.Id).Where(l => !l.IsBlocked && l.IsConfirm).ToList(); foreach (var l in lotsTemp) { lots.Add(l.ToLotRowViewModel()); } } } } else { lots = _lotService.GetAllLotEntities().Where(l => l.CategoryName == categoryName && !l.IsBlocked && l.IsConfirm) .Select(l => l.ToLotRowViewModel()) .ToList(); } return(PartialView("_LotRows", lots)); }
public void Execute(IJobExecutionContext context) { var lots = _lotService.GetAllLotEntities().Where(l => !l.IsSold && l.EndDate <= DateTime.Now).ToList(); if (lots != null) { for (var i = 0; i < lots.Count(); i++) { lots[i].IsSold = true; _lotService.UpdateLot(lots[i]); } } }
public IEnumerable <LotViewModel> GetLots() { return(_lotService.GetAllLotEntities().Select(l => l.ToMvcLot()).ToList()); }