public async Task <IActionResult> Details(int productId)
        {
            ProductDto product = null;

            try
            {
                product = await _ProductFacade.GetProduct(productId);
            }
            catch (HttpRequestException)
            {
                _logger.LogWarning("Exception Occured using Product Facade");
                product = null;
            }

            ProductViewModel viewModel = new ProductViewModel
            {
                ProductId   = product.ProductId,
                Name        = product.Name,
                Description = product.Description,
                Quantity    = product.Quantity,
                BrandId     = product.BrandId,
                Brand       = product.Brand,
                CategoryId  = product.CategoryId,
                Category    = product.Category,
                Price       = product.Price
            };

            return(View(viewModel));
        }
        public async Task <IActionResult> AddItem([FromQuery] int ProductId)
        {
            ProductDto product = null;

            try
            {
                product = await _productFacade.GetProduct(ProductId);
            }
            catch (HttpRequestException)
            {
                _logger.LogWarning("Exception Occured using Basket Facade");
                product = null;
            }

            BasketItemViewModel viewModel = new BasketItemViewModel
            {
                ProductId   = product.ProductId,
                Name        = product.Name,
                Description = product.Description,
                BrandId     = product.BrandId,
                Brand       = product.Brand,
                CategoryId  = product.CategoryId,
                Category    = product.Category,
                Price       = product.Price
            };

            return(View(viewModel));
        }
Beispiel #3
0
        public ActionResult InitEdit(string jsonData = "{}")
        {
            ProductViewModel productVM = null;

            _commPoolFacade = new CommPoolFacade();

            var toRTStatuses = new Dictionary <string, string>();
            var fromStatuses = _commPoolFacade.GetSRStatusSelectList();
            var toLFStatuses = new Dictionary <string, string>(fromStatuses);
            ProductSearchFilter searchFilter = JsonConvert.DeserializeObject <ProductSearchFilter>(jsonData);

            if (TempData["productVM"] != null)
            {
                productVM = (ProductViewModel)TempData["productVM"];

                if (productVM.ToSRStatusRightId != null && productVM.ToSRStatusRightId.Count > 0)
                {
                    foreach (var s in productVM.ToSRStatusRightId)
                    {
                        var statusId   = s.ConvertToString();
                        var statusName = toLFStatuses[statusId];
                        toLFStatuses.RemoveByValue(statusId);
                        toRTStatuses.Add(statusId, statusName);
                    }
                }
            }
            else
            {
                productVM = new ProductViewModel(searchFilter);

                if (searchFilter != null)
                {
                    _productFacade = new ProductFacade();
                    ProductSREntity product = _productFacade.GetProduct(searchFilter);

                    if (product != null)
                    {
                        productVM.FromSRStatusId   = product.FromSRStatusId;
                        productVM.ProductGroupId   = product.ProductGroupId;
                        productVM.ProductGroupName = product.ProductGroupName;
                        productVM.ProductId        = product.ProductId;
                        productVM.ProductName      = product.ProductName;
                        productVM.CampaignId       = product.CampaignId;
                        productVM.CampaignName     = product.CampaignName;
                        productVM.TypeId           = product.TypeId;
                        productVM.TypeName         = product.TypeName;
                        productVM.AreaId           = product.AreaId;
                        productVM.AreaName         = product.AreaName;
                        productVM.SubAreaId        = product.SubAreaId;
                        productVM.SubAreaName      = product.SubAreaName;
                        productVM.IsEdit           = product.IsEdit;

                        productVM.CreateUser  = product.CreateUser != null ? product.CreateUser.FullName : "";
                        productVM.CreatedDate = product.CreatedDate.FormatDateTime(Constants.DateTimeFormat.DefaultFullDateTime);
                        productVM.UpdateDate  = product.Updatedate.FormatDateTime(Constants.DateTimeFormat.DefaultFullDateTime);
                        productVM.UpdateUser  = product.UpdateUser != null ? product.UpdateUser.FullName : "";

                        toRTStatuses = product.ToSRStatusList.ToDictionary(x => x.SRStatusId.ConvertToString(), x => x.SRStatusName);
                        productVM.ToSRStatusRightList = new MultiSelectList(toRTStatuses, "Key", "Value");

                        foreach (var s in toRTStatuses)
                        {
                            toLFStatuses.RemoveByValue(s.Key);
                        }
                    }
                }
            }

            productVM.FromStatusList      = new SelectList((IEnumerable)fromStatuses, "Key", "Value", string.Empty);
            productVM.ToSRStatusLeftList  = new MultiSelectList(toLFStatuses, "Key", "Value");
            productVM.ToSRStatusRightList = new MultiSelectList(toRTStatuses, "Key", "Value");

            if (productVM.IsEdit == false)
            {
                // default UserLogin
                if (this.UserInfo != null)
                {
                    var today = DateTime.Now;
                    productVM.CreateUser  = this.UserInfo.FullName;
                    productVM.CreatedDate = today.FormatDateTime(Constants.DateTimeFormat.DefaultFullDateTime);
                    productVM.UpdateDate  = today.FormatDateTime(Constants.DateTimeFormat.DefaultFullDateTime);
                    productVM.UpdateUser  = this.UserInfo.FullName;
                }
            }


            return(View("~/Views/Product/Edit.cshtml", productVM));
        }
Beispiel #4
0
        public void AddToBasket(Guid saleProductId)
        {
            var product = _productFacade.GetProduct(saleProductId);

            User.AddToBasket(product);
        }
Beispiel #5
0
 public ProductDTO GetProduct(string productId)
 {
     return(productFacade.GetProduct(productId));
 }
        public string GetProduct(string productId)
        {
            var product = _productFacade.GetProduct(productId);

            return(string.Format("Name: {0}, Id: {1}, Price: {2}", product.GetName(), product.ProductId, product.GetUnitPrice()));
        }
        public ActionResult View(Guid id)
        {
            var product = _productFacade.GetProduct(id);

            return(View(product));
        }