public async Task <ActionResult> Index(PriceHedgePage currentPage, string pArea, string period, string priskey, string grain, string pItemId, string pItem, string agreement, string pid, string agreementId = "") { var supplier = UserManager.GetActiveCustomer(HttpContext); if (SiteUser == null || supplier == null) { ViewData["NotLoggedIn"] = true; return(View("~/Views/AppPages/PriceHedgePage/PriceHedge.cshtml", new PriceHedgeViewModel(currentPage))); } if (string.IsNullOrEmpty(pArea) || string.IsNullOrEmpty(period) || string.IsNullOrEmpty(priskey) || string.IsNullOrEmpty(pid)) { ViewData["IncorrectParams"] = true; return(View("~/Views/AppPages/PriceHedgePage/PriceHedge.cshtml", new PriceHedgeViewModel(currentPage))); } agreement = string.IsNullOrWhiteSpace(agreement) ? AgreementType.SportAndForwardAvtal : agreement; var purchaseDateObject = GenerateFromDatePeriod(period); int agrId; int.TryParse(agreementId, out agrId); var model = new PriceHedgeViewModel(currentPage) { PriceLow = SettingPage.PurchasePriceLow, CommitQuantityMin = 12, //Need to get from service instead of TimeWithClock = $"{DateTime.Now:dd MMM yyyy} klockan {DateTime.Now:HH:mm}", SelectedPriceArea = (await _agreementRepository.GetSelectedPriceArea(supplier.CustomerNo)), AgreementTypeName = GetAgreementTypeName(priskey, agreement), AgreementHeading = GetAgreementHeading(agreement), ProductItemName = pItem, DeliveryPeriod = $"{purchaseDateObject.ValidFrom:yyyy-MM-dd} - {purchaseDateObject.ValidTo:yyyy-MM-dd}", RegisterDate = $"{DateTime.Now:yyyy-MM-dd}", Customer = (await _agreementRepository.GetCustomerAsync(supplier.CustomerNo)) ?? new Customer(), PurchaseAgreementUrl = string.IsNullOrEmpty(pid) ? "#" : GetPurchaseAgreementPageUrl(pid), PriceHedgeForm = new PriceHedgeFormModel { PriceArea = int.Parse(pArea), ProductItemId = pItemId, GrainType = grain, PriceType = priskey, PriceWatchEndDate = DateTime.Now, HarvestYear = purchaseDateObject.HarvestYear, ValidTo = purchaseDateObject.ValidTo, ValidFrom = purchaseDateObject.ValidFrom, AgreementType = string.IsNullOrEmpty(agreement) ? AgreementType.SportAndForwardAvtal : agreement, AgreementId = agrId }, User = SiteUser, }; return(View("~/Views/AppPages/PriceHedgePage/PriceHedge.cshtml", model)); }
public async Task <ActionResult> Index(DryingAgreementPage currentPage) { var supplier = UserManager.GetActiveCustomer(HttpContext); if (SiteUser == null || supplier == null) { TempData["NotLoggedIn"] = true; return(View("~/Views/AppPages/DryingAgreementPage/DryingAgreement.cshtml", new DryingAgreementViewModel(currentPage))); } var dryingAgreement = await _purchaseRepository.GetDryingAgreementAsync(); var model = new DryingAgreementViewModel(currentPage) { Agreement = dryingAgreement ?? new DryingAgreement(), Customer = (await _purchaseRepository.GetCustomerAsync(supplier.CustomerNo)) ?? new Customer(), }; return(View("~/Views/AppPages/DryingAgreementPage/DryingAgreement.cshtml", model)); }