public ActionResult CreateLot(LotCreateViewModel viewModel, IEnumerable<HttpPostedFileBase> images) { if (ModelState.IsValid) { var seller = _userService.GetUserEntityByLogin(User.Identity.Name); var category = _categoryService.GetByCategoryName(viewModel.SettedCategoryName); //GetAllCategoryEntities() //.FirstOrDefault(c => c.CategoryName == viewModel.SettedCategoryName); var lot = viewModel.ToLotEntity(); lot.BlockReason = String.Empty; lot.CategoryRefId = category.Id; lot.IsBlocked = false; lot.IsConfirm = false; lot.IsSold = false; lot.StartDate = DateTime.Now; lot.SellerLogin = seller.Login; lot.SellerEmail = seller.Email; lot.SellerRefId = seller.Id; _lotService.CreateLot(lot); StartSchedulerJob(lot.EndDate); return RedirectToAction("Index", "Lot"); } viewModel.Sections = LoadSections(); viewModel.Categories = LoadCategories(viewModel.SettedSectionName); return View(viewModel); }
public ActionResult CreateLot() { try { var sections = LoadSections(); var lotViewModel = new LotCreateViewModel() {Sections = sections, Categories = LoadCategories(sections.First().Text)}; return View(lotViewModel); } catch (Exception EX_NAME) { Log.LogError(EX_NAME); return RedirectToAction("Index", "Lot"); } }
public ActionResult EditLot(LotCreateViewModel viewModel) { if (ModelState.IsValid) { var lot = _lotService.GetLotEntity(viewModel.Id); var category = _categoryService.GetAllCategoryEntities() .FirstOrDefault(c => c.CategoryName == viewModel.SettedCategoryName); if (category != null) lot.CategoryRefId = category.Id; lot.LotName = viewModel.Name; lot.Discription = viewModel.Discription; lot.EndDate = viewModel.EndDate; lot.IsConfirm = false; _lotService.UpdateLot(lot); StartSchedulerJob(lot.EndDate); return RedirectToAction("LotDetails", "Lot", new { id = viewModel.Id }); } return View(viewModel); }
public ActionResult CategoryInSectionPartial(string sectionName) { var lotViewModel = new LotCreateViewModel() {Categories = LoadCategories(sectionName)}; return PartialView("_CategoryInSection", lotViewModel); }
public ActionResult EditLot(int id) { var lot = _lotService.GetLotEntity(id); var sectionId = _categoryService.GetCategoryEntity(lot.CategoryRefId).SectionRefId; var sections = LoadSections(); var section = _sectionService.GetSectionEntity(_categoryService.GetCategoryEntity(lot.CategoryRefId).SectionRefId); var lotViewModel = new LotCreateViewModel() { Sections = sections, Categories = LoadCategories(section.SectionName), Id = lot.Id, Name = lot.LotName, SettedSectionName = _sectionService.GetSectionEntity(sectionId).SectionName, Discription = lot.Discription, EndDate = lot.EndDate, SettedCategoryName = lot.CategoryName, StartingBid = lot.StartingBid }; return View(lotViewModel); }