Exemple #1
0
        public ActionResult AddProduct(SupplieProductItem request)
        {
            //kiem tra da ton tai trong he thong chua
            var product = _da.CheckExistSupplierProduct(request.CateId, request.SupplierId);

            if (product)
            {
                return(Json(new JsonMessage()
                {
                    Erros = true, Message = "Sản phẩm đã tồn tại trong hệ thống"
                }, JsonRequestBehavior.AllowGet));
            }

            var obj = new DN_SupplierProduct()
            {
                ProductId  = request.CateId,
                Amount     = request.Quantity,
                SupplierId = request.SupplierId,
                IsDelete   = false,
            };

            _da.AddProduct(obj);
            var result = _da.Save();

            return(Json(new JsonMessage()
            {
                Erros = false
            }, JsonRequestBehavior.AllowGet));
        }
        public ActionResult AjaxForm(int supplierId)
        {
            var lstCate = _categoryApi.GetChildByParentId(false);

            ViewBag.lstCate    = lstCate;
            ViewBag.supplierId = supplierId;
            var model = new SupplieProductItem()
            {
                SupplierId = supplierId
            };


            if (DoAction == ActionType.Edit)
            {
                model = _api.GetSupplierProductById(ArrId.FirstOrDefault());
            }
            ViewBag.Action = DoAction;
            return(View(model));
        }
Exemple #3
0
        public async Task <BaseResponse <bool> > AddProduct(SupplieProductItem request)
        {
            var urlJson = $"{Domain}Supplie/AddProduct";

            return(await PostDataAsync <BaseResponse <bool> >(urlJson, request));
        }
        public async Task <ActionResult> Actions()
        {
            var msg = new JsonMessage {
                Erros = false
            };
            var url   = Request.Form.ToString();
            var lstID = string.Join(",", ArrId);

            switch (DoAction)
            {
            case ActionType.Add:
                var request = new SupplieProductItem();
                UpdateModel(request);
                var result = await _api.AddProduct(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:
                if (_api.Update(url) == 0)
                {
                    msg.Erros   = true;
                    msg.Message = "Có lỗi xảy ra!";
                    break;
                }
                msg.Message = "Cập nhật dữ liệu thành công !";
                break;

            case ActionType.Show:
                if (_api.Show(url) == 0)
                {
                    msg.Erros   = true;
                    msg.Message = "Có lỗi xảy ra!";
                    break;
                }
                _api.Show(lstID);
                msg.Message = "Cập nhật dữ liệu thành công !";
                break;

            case ActionType.Hide:
                if (_api.Hide(url) == 0)
                {
                    msg.Erros   = true;
                    msg.Message = "Có lỗi xảy ra!";
                    break;
                }
                _api.Hide(lstID);
                msg.Message = "Cập nhật dữ liệu thành công !";
                break;

            case ActionType.Delete:
                _api.Delete(lstID);
                msg.Message = "Cập nhật thành công.";
                break;
            }
            if (string.IsNullOrEmpty(msg.Message))
            {
                msg.Message = "Không có hành động nào được thực hiện.";
                msg.Erros   = true;
            }
            return(Json(msg, JsonRequestBehavior.AllowGet));
        }