Ejemplo n.º 1
0
        public ActionResult Add(SupplierAmountProductItem request)
        {
            var model = new Base.SupplierAmountProduct()
            {
                SupplierId      = request.SupplierId,
                ProductID       = request.ProductID,
                PublicationDate = request.PublicationDate,
                ExpireDate      = request.ExpireDate,
                IsAlwayExist    = request.IsAlwayExist,
                AmountEstimate  = request.AmountEstimate,
                AmountPayed     = request.AmountPayed,
                CallDate        = request.CallDate,
                Note            = request.Note,
                IsDelete        = false,
                CreatedDate     = DateTime.Now.TotalSeconds()
            };

            var temp = _cateRecipeDa.GetItemByCateIdUser(request.ProductID ?? 0);

            if (temp != null)
            {
                var lstProduct = temp.LstCategoryRecipeItems.Select(item => new Shop_Product_Comingsoon
                {
                    ProductID   = item.ProductId,
                    DateEx      = request.PublicationDate,
                    Quantity    = request.AmountEstimate * item.Quantity,
                    Price       = item.PriceProduct,
                    TotalPrice  = request.AmountEstimate * item.Quantity * item.PriceProduct,
                    QuantityOut = 0,
                })
                                 .ToList();

                foreach (var itema in temp.LstMappingCategoryRecipeItems)
                {
                    temp = _cateRecipeDa.GetItemByCateIdUser(itema.CategoryID ?? 0);
                    if (temp != null)
                    {
                        lstProduct.AddRange(temp.LstCategoryRecipeItems.Select(item1 => new Shop_Product_Comingsoon
                        {
                            ProductID   = item1.ProductId,
                            DateEx      = request.PublicationDate,
                            Quantity    = request.AmountEstimate * item1.Quantity,
                            Price       = item1.PriceProduct,
                            TotalPrice  = request.AmountEstimate * item1.Quantity * item1.PriceProduct,
                            QuantityOut = 0,
                        }));
                    }
                }
                model.Shop_Product_Comingsoon = lstProduct;
                _da.Add(model);
                _da.Save();
            }
            return(Json(new JsonMessage()
            {
                Erros = false
            }, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 2
0
        public ActionResult Update(SupplierAmountProductItem request)
        {
            var model = _da.GetById(request.ID);

            model.AmountEstimate  = request.AmountEstimate;
            model.AmountPayed     = request.AmountPayed;
            model.CallDate        = request.CallDate;
            model.IsAlwayExist    = request.IsAlwayExist;
            model.ExpireDate      = request.ExpireDate;
            model.Note            = request.Note;
            model.ProductID       = request.ProductID;
            model.SupplierId      = request.SupplierId;
            model.UserActiveId    = request.UserActiveId;
            model.PublicationDate = request.PublicationDate;
            model.Shop_Product_Comingsoon.Clear();
            var temp = _cateRecipeDa.GetItemByCateIdUser(request.ProductID ?? 0);

            if (temp != null)
            {
                var lstProduct = temp.LstCategoryRecipeItems.Select(item => new Shop_Product_Comingsoon
                {
                    ProductID   = item.ProductId,
                    DateEx      = request.PublicationDate,
                    Quantity    = request.AmountEstimate * item.Quantity,
                    Price       = item.PriceProduct,
                    TotalPrice  = request.AmountEstimate * item.Quantity * item.PriceProduct,
                    QuantityOut = 0,
                })
                                 .ToList();

                foreach (var itema in temp.LstMappingCategoryRecipeItems)
                {
                    temp = _cateRecipeDa.GetItemByCateIdUser(itema.CategoryID ?? 0);
                    if (temp != null)
                    {
                        lstProduct.AddRange(temp.LstCategoryRecipeItems.Select(item1 => new Shop_Product_Comingsoon
                        {
                            ProductID   = item1.ProductId,
                            DateEx      = request.PublicationDate,
                            Quantity    = request.AmountEstimate * item1.Quantity,
                            Price       = item1.PriceProduct,
                            TotalPrice  = request.AmountEstimate * item1.Quantity * item1.PriceProduct,
                            QuantityOut = 0,
                        }));
                    }
                }
                model.Shop_Product_Comingsoon = lstProduct;
                _da.Save();
            }

            return(Json(new JsonMessage()
            {
                Erros = false
            }, JsonRequestBehavior.AllowGet));
        }
        public async Task <ActionResult> AjaxForm()
        {
            var lstCate = _categoryApi.GetChildByParentId(false);

            ViewBag.lstCate = lstCate;
            var model = new SupplierAmountProductItem()
            {
                ExpireDate      = DateTime.Now.TotalSeconds(),
                PublicationDate = DateTime.Now.TotalSeconds(),
                CallDate        = DateTime.Now.TotalSeconds()
            };

            ViewBag.lstSupplier = _api.GetList();
            if (DoAction == ActionType.Edit)
            {
                model = await _apiSupplierAmount.GetById(ArrId.FirstOrDefault());
            }
            ViewBag.Action = DoAction;
            return(View(model));
        }
        public async Task <ActionResult> Actions()
        {
            var msg = new JsonMessage {
                Erros = false
            };
            var url   = Request.Form.ToString();
            var lstID = string.Join(",", ArrId);
            var temp  = new SupplierAmountProductFormItem();

            try
            {
                switch (DoAction)
                {
                case ActionType.Add:


                    UpdateModel(temp);
                    var request = new SupplierAmountProductItem()
                    {
                        SupplierId      = temp.SupplierId ?? 1,
                        ProductID       = temp.ProductID,
                        PublicationDate = temp._PublicationDate.StringToDecimal(),
                        AmountEstimate  = temp.AmountEstimate ?? 0,
                        AmountPayed     = temp.AmountPayed ?? 0,
                        CallDate        = temp._CallDate.StringToDecimal(),
                        ExpireDate      = temp._ExpireDate.StringToDecimal(),
                        IsAlwayExist    = temp.IsAlwayExist == true,
                        Note            = temp.Note,
                        UserActiveId    = UserItem.UserId,
                    };
                    var result = await _apiSupplierAmount.Add(request);

                    if (result.Erros)
                    {
                        msg.Erros   = true;
                        msg.Message = result.Message;
                        break;
                    }
                    msg.Message = "Cập nhật dữ liệu thành công !";
                    break;

                case ActionType.Edit:
                    UpdateModel(temp);
                    var requestUpdate = new SupplierAmountProductItem()
                    {
                        SupplierId      = temp.SupplierId ?? 1,
                        ProductID       = temp.ProductID,
                        PublicationDate = temp._PublicationDate.StringToDecimal(),
                        AmountEstimate  = temp.AmountEstimate ?? 0,
                        AmountPayed     = temp.AmountPayed ?? 0,
                        CallDate        = temp._CallDate.StringToDecimal(),
                        ExpireDate      = temp._ExpireDate.StringToDecimal(),
                        IsAlwayExist    = temp.IsAlwayExist == true,
                        Note            = temp.Note,
                        UserActiveId    = UserItem.UserId,
                    };
                    UpdateModel(requestUpdate);

                    await _apiSupplierAmount.Update(requestUpdate);

                    msg.Message = "Cập nhật dữ liệu thành công !";
                    break;

                case ActionType.Delete:
                    await _apiSupplierAmount.Delete(ArrId.FirstOrDefault());

                    msg.Message = "Cập nhật thành công.";
                    break;
                }
            }
            catch (Exception e)
            {
                msg.Erros   = true;
                msg.Message = e.ToString();
            }


            return(Json(msg, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 5
0
        public async Task <BaseResponse <SupplieProductResponse> > Update(SupplierAmountProductItem request)
        {
            var urlJson = $"{Domain}SupplierAmountProduct/Update";

            return(await PostDataAsync <BaseResponse <SupplieProductResponse> >(urlJson, request));
        }