public ActionResult Pick() { var model = new FairViewModel(); var currentFair = Repository.GetCurrentFair(); var currentStep = 0; model.Fair = currentFair; model.CurrentStep = currentStep; model.NumberOfPhases = NUMBER_OF_STEPS; Session[CURRENT_STEP] = currentStep; return(View(model)); }
public async Task <ActionResult> Index() { var fairList = await _fairClient.GetAllFairs(); var sectorList = await _sectorClient.GetAllAsync(); FairViewModel vm = new FairViewModel() { Fairs = fairList, Sectors = sectorList }; return(View(vm)); }
public ActionResult Pick(FairViewModel model) { if (Session[CURRENT_STEP] == null) { return(RedirectToAction(nameof(Pick))); } int currentStep = (int)Session[CURRENT_STEP]; Fair currentFair = Repository.GetCurrentFair(); model.Fair = currentFair; model.NumberOfPhases = NUMBER_OF_STEPS; if (string.IsNullOrEmpty(model.UserBarCode) && currentStep == 0) { ModelState.AddModelError(nameof(FairViewModel.UserBarCode), "Veuillez indiquez le code à barres du vendeur."); } if (ModelState.IsValid) { switch (currentStep) { case 0: ApplicationUser seller = Repository.GetUserBy(BarCode: model.UserBarCode.Trim().ToUpper()); if (seller == null) { return(RedirectToAction(nameof(Pick))); } Session[CURRENT_STEP] = 1; Session[SELLER] = seller.Id; model.CurrentStep = 1; model.User = seller; model.UserOffers = seller.Offers; model.FairOffers = currentFair.Offers; break; case 1: if (Session[SELLER] == null) { return(RedirectToAction(nameof(Pick))); } ApplicationUser seller1 = Repository.GetUserBy(Id: Session[SELLER] as string); Session[SELLER_PICKED_ARTICLES] = currentFair.Offers.Intersect(seller1.Offers) .Where(offer => offer.Article.FairState == ArticleFairState.PICKED) .ToList() .ConvertAll(new Converter <Offer, string>(offer => offer.Id.ToString())); Session[CURRENT_STEP] = 2; model.CurrentStep = 2; model.User = seller1; break; case 2: return(RedirectToAction(nameof(Pick))); } } return(View(model)); }