public ActionResult Coppy(string key)
        {
            var msg = new JsonMessage(false, "Coppy dữ liệu thành công.");

            try
            {
                if (key == Keyapi)
                {
                    var model    = _da.GetById(ItemId);
                    var modelNew = new Shop_Product_Detail
                    {
                        Name        = model.Name + " coppy",
                        NameAscii   = model.NameAscii + "-coppy",
                        Code        = model.Code + "-coppy",
                        Price       = model.Price,
                        QuantityDay = model.QuantityDay,
                        IsShow      = model.IsShow,
                        IsDelete    = false,
                        CateID      = model.CateID,
                        PictureID   = model.PictureID,
                        UnitID      = model.UnitID,
                        StartDate   = DateTime.Now.TotalSeconds(),
                        Description = model.Description,
                    };
                    foreach (var item in model.Shop_Product)
                    {
                        var objProduct = new Shop_Product
                        {
                            SizeID      = item.SizeID,
                            PriceNew    = item.PriceNew,
                            PriceOld    = item.PriceOld,
                            QuantityDay = model.QuantityDay,
                            Quantity    = 0,
                            CreateDate  = model.StartDate,
                            CodeSku     = model.Code,
                            IsDelete    = false,
                            IsShow      = model.IsShow
                        };

                        modelNew.Shop_Product.Add(objProduct);
                    }

                    _da.Add(modelNew);
                    _da.Save();
                }
            }
            catch (Exception ex)
            {
                msg.Erros   = true;
                msg.Message = "Dữ liệu chưa được Coppy.";
                Log2File.LogExceptionToFile(ex);
            }
            return(Json(msg, JsonRequestBehavior.AllowGet));
        }
예제 #2
0
        public ActionResult Add(string key, string code)
        {
            var msg   = new JsonMessage(false, "Thêm mới dữ liệu thành công.");
            var model = new Shop_Product_Detail();

            try
            {
                if (key != Keyapi)
                {
                    return(Json(0, JsonRequestBehavior.AllowGet));
                }
                UpdateModel(model);
                var CodeSku = Request["CodeSku"];
                model.IsDelete = false;


                var lstPicture = Request["Value_DefaultImages"];
                if (!string.IsNullOrEmpty(lstPicture))
                {
                    var lstInt = FDIUtils.StringToListInt(lstPicture);
                    model.PictureID = lstInt.FirstOrDefault();
                }
                model.Name      = HttpUtility.UrlDecode(model.Name);
                model.NameAscii = FDIUtils.Slug(model.Name);
                model.Code      = HttpUtility.UrlDecode(CodeSku);
                _detailDa.Add(model);
                _detailDa.Save();
                var CreateBy = Request["CreateBy"];
                //var Percent = Request["Percent"];
                var product = new Shop_Product
                {
                    ProductDetailID = model.ID,
                    CodeSku         = model.Code,
                    Quantity        = model.QuantityDay,

                    CreateBy   = CreateBy,
                    CreateDate = DateTime.Now.TotalSeconds(),
                    IsShow     = true,
                    IsDelete   = false,
                };

                _da.Add(product);
                _da.Save();
            }
            catch (Exception ex)
            {
                msg.Erros   = true;
                msg.Message = "Dữ liệu Chưa được thêm mới.";
                Log2File.LogExceptionToFile(ex);
            }
            return(Json(msg, JsonRequestBehavior.AllowGet));
        }
        public ActionResult AjaxForm()
        {
            var model = new Shop_Product_Detail();

            if (DoAction == ActionType.Edit)
            {
                model = _da.GetById(ArrId.FirstOrDefault());
            }
            ViewBag.Action     = DoAction;
            ViewBag.ActionText = ActionText;

            return(View(model));
        }
        public ActionResult Add(string key, string codelogin)
        {
            var msg = new JsonMessage(false, "Thêm mới dữ liệu thành công.");

            try
            {
                var model = new Shop_Product_Detail();
                UpdateModel(model);
                var lstPicture = Request["Value_ImagesProducts"];
                if (!string.IsNullOrEmpty(lstPicture))
                {
                    model.Gallery_Picture2 = _da.GetListPictureByArrId(lstPicture);
                }

                model.Name      = HttpUtility.UrlDecode(model.Name);
                model.NameAscii = FomatString.Slug(model.Name);
                model.IsDelete  = false;
                if (IsAdmin)
                {
                    model.IsShow = true;
                }
                else
                {
                    model.IsShow = false;
                }
                var objProduct = new Shop_Product
                {
                    QuantityDay = model.QuantityDay,
                    Quantity    = 0,
                    CreateDate  = model.StartDate,
                    CodeSku     = model.Code,
                    IsDelete    = false,
                    IsShow      = model.IsShow
                };
                model.Shop_Product.Add(objProduct);
                _da.Add(model);
                _da.Save();
            }
            catch (Exception ex)
            {
                msg.Erros   = true;
                msg.Message = "Dữ liệu chưa được thêm mới.";
                Log2File.LogExceptionToFile(ex);
            }
            return(Json(msg, JsonRequestBehavior.AllowGet));
        }
        public ActionResult Actions()
        {
            var msg     = new JsonMessage();
            var product = new Shop_Product_Detail();
            List <Shop_Product_Detail> lstProduct;
            StringBuilder stbMessage;

            var lsttag    = Request["values-arr-tag"];
            var images    = Request["Value_Images"];
            var lstCate   = Request["Value_CategoryValues"];
            var lstimages = Request["Value_ImagesProducts"];

            switch (DoAction)
            {
            case ActionType.Add:
                try
                {
                    UpdateModel(product);
                    product.DateCreate = DateTime.Now.TotalSeconds();
                    product.IsDelete   = false;
                    //product.AgencyID = Utility.AgencyId;
                    product.IsShow = true;
                    //product.LanguageId = Fdisystem.LanguageId;
                    if (!string.IsNullOrEmpty(images))
                    {
                        product.PictureID = Convert.ToInt32(images);
                    }
                    if (!string.IsNullOrEmpty(lstCate))
                    {
                        product.Categories = _da.GetListCateByArrId(lstCate);
                    }
                    if (!string.IsNullOrEmpty(lstimages))
                    {
                        product.Gallery_Picture2 = _da.GetListPictureByArrId(lstimages);
                    }
                    if (string.IsNullOrEmpty(lsttag))
                    {
                        product.System_Tag = _da.GetListIntTagByArrId(lsttag);
                    }
                    _da.Add(product);
                    _da.Save();
                    msg = new JsonMessage
                    {
                        Erros   = false,
                        ID      = product.ID.ToString(),
                        Message = string.Format("Đã thêm mới sản phẩm: <b>{0}</b>", Server.HtmlEncode(product.Name))
                    };
                }
                catch (Exception)
                {
                }
                break;

            case ActionType.Edit:
                try
                {
                    product = _da.GetById(ArrId.FirstOrDefault());
                    UpdateModel(product);
                    product.Name = Convert.ToString(product.Name);
                    if (!string.IsNullOrEmpty(images))
                    {
                        product.PictureID = Convert.ToInt32(images);
                    }
                    product.Categories.Clear();
                    if (!string.IsNullOrEmpty(lstCate))
                    {
                        product.Categories = _da.GetListCateByArrId(lstCate);
                    }
                    product.Gallery_Picture2.Clear();
                    if (!string.IsNullOrEmpty(lstimages))
                    {
                        product.Gallery_Picture2 = _da.GetListPictureByArrId(lstimages);
                    }
                    product.System_Tag.Clear();
                    if (!string.IsNullOrEmpty(lsttag))
                    {
                        product.System_Tag = _da.GetListIntTagByArrId(lsttag);
                    }
                    _da.Save();
                    msg = new JsonMessage
                    {
                        Erros   = false,
                        ID      = product.ID.ToString(),
                        Message = string.Format("Đã cập nhật sản phẩm: <b>{0}</b>", Server.HtmlEncode(product.Name))
                    };
                }
                catch (Exception)
                {
                }
                break;

            case ActionType.Delete:
                lstProduct = _da.GetListProductDetailByArrId(ArrId);
                stbMessage = new StringBuilder();
                foreach (var item in lstProduct)
                {
                    item.IsDelete = true;
                    stbMessage.AppendFormat("Đã xóa <b>{0}</b>.<br />", Server.HtmlEncode(item.Name));
                }
                msg.ID = string.Join(",", ArrId);
                _da.Save();
                msg.Message = stbMessage.ToString();
                break;

            case ActionType.Show:
                lstProduct = _da.GetListProductDetailByArrId(ArrId);
                stbMessage = new StringBuilder();
                foreach (var item in lstProduct)
                {
                    item.IsShow = true;
                    stbMessage.AppendFormat("Đã hiển thị <b>{0}</b>.<br />", Server.HtmlEncode(item.Name));
                }
                _da.Save();
                msg.ID      = string.Join(",", lstProduct.Select(o => o.ID));
                msg.Message = stbMessage.ToString();
                break;

            case ActionType.Hide:
                lstProduct = _da.GetListProductDetailByArrId(ArrId);
                stbMessage = new StringBuilder();
                foreach (var item in lstProduct)
                {
                    item.IsShow = false;
                    stbMessage.AppendFormat("Đã ẩn <b>{0}</b>.<br />", Server.HtmlEncode(item.Name));
                }
                _da.Save();
                msg.ID      = string.Join(",", lstProduct.Select(o => o.ID));
                msg.Message = stbMessage.ToString();
                break;

            case ActionType.UserModule:
                var model = _da.GetProductById(ArrId.FirstOrDefault());
                product = _da.GetById(ArrId.FirstOrDefault());
                var list = new List <Shop_Product>();
                foreach (var item in model)
                {
                    var name = Request["Size_old" + item.ID];
                    if (string.IsNullOrEmpty(name))
                    {
                        list.Add(item);
                    }
                    else
                    {
                        item.SizeID = int.Parse(name);
                        //item.SizeID = ConvertUtil.ToInt32(Request["Size_old" + item.ID]);
                        //item.PriceNew = ConvertUtil.ToDecimal(Request["PriceNew_old" + item.ID]);
                        //item.PriceOld = ConvertUtil.ToDecimal(Request["PriceOld_old" + item.ID]);
                    }
                }
                foreach (var item in list)
                {
                    _da.DeleteProduct(item);
                }
                var stt = ConvertUtil.ToInt32(Request["do_stt"]);
                for (int i = 1; i <= stt; i++)
                {
                    var name = Request["Size_add_" + i];
                    if (!string.IsNullOrEmpty(name))
                    {
                        var obj = new Shop_Product()
                        {
                            ProductDetailID = product.ID,
                            //PriceNew = ConvertUtil.ToDecimal(Request["PriceNew_add_" + i]),
                            //PriceOld = ConvertUtil.ToDecimal(Request["PriceOld_add_" + i]),
                            SizeID = int.Parse(name),
                            //SizeID = ConvertUtil.ToInt32(Request["Size_add_" + i]),
                            IsShow   = true,
                            IsDelete = false,
                        };
                        _da.AddProduct(obj);
                    }
                }
                _da.Save();
                msg = new JsonMessage
                {
                    Erros   = false,
                    ID      = product.ID.ToString(),
                    Message = string.Format("Đã thêm mới sản phẩm: <b>{0}</b>", Server.HtmlEncode(product.Name))
                };
                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));
        }
예제 #6
0
 public void Delete(Shop_Product_Detail shopProductDetail)
 {
     FDIDB.Shop_Product_Detail.Remove(shopProductDetail);
 }
예제 #7
0
 public void Add(Shop_Product_Detail shopProductDetail)
 {
     FDIDB.Shop_Product_Detail.Add(shopProductDetail);
 }
예제 #8
0
        public async Task <BaseResponse <bool> > UpdateApi(Shop_Product_Detail obj, int id)
        {
            var urlJson = string.Format("{0}ShopProductDetail/Update", _url);

            return(await PostDataAsync <BaseResponse <bool> >(urlJson, obj, id));
        }
예제 #9
0
        public async Task <BaseResponse <bool> > AddApi(Shop_Product_Detail obj)
        {
            var urlJson = string.Format("{0}ShopProductDetail/Add", _url);

            return(await PostDataAsync <BaseResponse <bool> >(urlJson, obj));
        }
예제 #10
0
        public async Task <ActionResult> Actions()
        {
            var msg = new JsonMessage();
            var url = Request.Form.ToString();

            url = HttpUtility.UrlDecode(url);
            var model      = new Shop_Product_Detail();
            var lstArrId   = "";
            var lstPicture = Request["Value_ImagesProducts"];

            switch (DoAction)
            {
            case ActionType.Add:
                UpdateModel(model);
                model.IsDelete = false;
                if (IsAdmin)
                {
                    model.IsShow = true;
                }
                else
                {
                    model.IsShow = false;
                }
                var objProduct = new Shop_Product
                {
                    QuantityDay = model.QuantityDay,

                    Quantity   = 0,
                    CreateDate = model.StartDate,
                    CodeSku    = model.Code,
                    IsDelete   = false,
                    IsShow     = model.IsShow
                };
                model.Shop_Product.Add(objProduct);
                if (!string.IsNullOrEmpty(lstPicture))
                {
                    model.Gallery_Picture2 = _da.GetListPictureByArrId(lstPicture);
                }
                _da.Add(model);
                _da.Save();
                break;

            case ActionType.View:
                msg = _api.Coppy(UserItem.AgencyID, ArrId.FirstOrDefault());
                break;

            case ActionType.Edit:
                model = _da.GetById(ArrId.FirstOrDefault());
                UpdateModel(model);
                if (!IsAdmin)
                {
                    model.IsShow = false;
                }
                model.Gallery_Picture2.Clear();
                if (!string.IsNullOrEmpty(lstPicture))
                {
                    model.Gallery_Picture2 = _da.GetListPictureByArrId(lstPicture);
                }
                _da.Save();
                break;

            case ActionType.Active:
                msg = _api.Active(url, CodeLogin(), UserItem.UserId);
                break;

            case ActionType.NotActive:
                msg = _api.NotActive(url, CodeLogin(), UserItem.UserId);
                break;

            case ActionType.UserModule:
                msg = _api.Addproduct(UserItem.AgencyID, url);
                break;

            case ActionType.Show:
                lstArrId = string.Join(",", ArrId);
                msg      = _api.ShowHide(lstArrId, true);
                break;

            case ActionType.Hide:
                lstArrId = string.Join(",", ArrId);
                msg      = _api.ShowHide(lstArrId, false);
                break;

            case ActionType.Delete:
                lstArrId = string.Join(",", ArrId);
                msg      = _api.Delete(lstArrId);
                break;

            default:
                msg.Message = "Bạn chưa được phân quyền cho chức năng này.";
                msg.Erros   = true;
                break;
            }
            return(Json(msg, JsonRequestBehavior.AllowGet));
        }