예제 #1
0
        public async Task <ActionResult> Index(PriceAlertPage currentPage)
        {
            var supplier = _usersManagementService.GetActiveCustomer(HttpContext);
            var result   = await _agreementRepository.GetPriceWatchAsync(supplier?.CustomerNo ?? string.Empty, _ticket);

            var priceWatchList = new List <PriceWatchView>();

            if (result?.Length > 0)
            {
                var resultList = result.ToList();
                foreach (var item in resultList)
                {
                    var priceWatch = new PriceWatchView()
                    {
                        Id           = item.Id,
                        Name         = item.Name + " " + item.ItemName,
                        Quantity     = item.AgreedQuantity,
                        Price        = item.Price,
                        PriceMin     = item.WatchPriceMin,
                        ContractType = item.AgreementType,
                        ValidTo      = item.WatchDate.ToString("yyyy-MM-dd"),
                        Activity     = GetActivityDisplay(item.Activity, item.AgreementType)
                    };

                    if (item.PriceList.Trim().Substring(0, 1) == "T")
                    {
                        priceWatch.DeliveryPeriod = item.ValidFrom.ToString("yyyy-MM-dd") + " - " +
                                                    item.ValidTo.ToString("yyyy-MM-dd");
                    }
                    else
                    {
                        priceWatch.DeliveryPeriod = "Spot";
                    }
                    priceWatchList.Add(priceWatch);
                }
            }
            var model = new PriceAlertPageViewModel(currentPage)
            {
                PriceWatchList = priceWatchList
            };

            return(View("~/Views/AppPages/PriceAlertPage/Index.cshtml", model));
        }