public ActionResult Add(string key, string json)
        {
            var model = new Shop_Product_Value();

            try
            {
                if (key != Keyapi)
                {
                    return(Json(0, JsonRequestBehavior.AllowGet));
                }
                UpdateModel(model);
                model.Name        = HttpUtility.UrlDecode(model.Name);
                model.NameAscii   = FomatString.Slug(model.Name);
                model.IsDeleted   = false;
                model.Quantity    = 0;
                model.QuantityOut = 0;
                _da.Add(model);
                _da.Save();
                return(Json(model.ID, JsonRequestBehavior.AllowGet));
            }
            catch (Exception)
            {
                return(Json(0, JsonRequestBehavior.AllowGet));
            }
        }
Exemple #2
0
        public ImportProductItem GetObjOne(string keword, int agencyId)
        {
            var date  = DateTime.Now.TotalSeconds();
            var name  = FomatString.Slug(keword);
            var query = from c in FDIDB.DN_ImportProduct
                        where c.BarCode == name
                        //&& c.AgencyId == agencyId
                        && c.Quantity > c.QuantityOut
                        select new ImportProductItem
            {
                GID        = c.GID,
                BarCode    = c.BarCode,
                PriceNew   = c.PriceNew,
                Name       = c.Product_Value.Shop_Product_Detail.Name,
                Price      = c.Price,
                Date       = c.Date,
                DateEnd    = c.DateEnd,
                Quantity   = 1,
                Value      = c.Value,
                IsDate     = true,        //c.Date < date && c.DateEnd >= date
                UrlPicture = c.Product_Value.Shop_Product_Detail.Gallery_Picture.Folder + c.Product_Value.Shop_Product_Detail.Gallery_Picture.Url,
            };

            return(query.Any() ? query.FirstOrDefault() : new ImportProductItem());
        }
        /// <summary>
        /// Trang chủ
        /// </summary>
        /// <param name="slug"></param>
        /// <param name="ctrId"></param>
        /// <param name="url"></param>
        /// <param name="cateId"></param>
        /// <param name="page"></param>
        /// <returns></returns>
        public PartialViewResult Index(string slug, int ctrId, string url, int cateId = 0, int pageId = 0, int page = 1)
        {
            var       stt     = (page - 1) * TotalpageH;
            const int rowPage = 15;
            var       total   = 0;
            var       keyword = "";
            var       text    = "";
            var       search  = slug.Contains("tim-kiem-san-pham");

            if (search)
            {
                text    = Request["keyword"];
                keyword = FomatString.Slug(text);
            }
            var pages = string.Format("/{0}-p{1}c{2}p", slug, pageId, cateId);
            var color = Request["color"];
            var size  = Request["size"];
            var sort  = Request["sort"];
            var model = new ModelShopProductDetailItem
            {
                CtrId    = ctrId,
                CtrUrl   = url,
                ListItem = !search?_detailBl.GetList(slug, page, rowPage, ref total, color, size, sort) : _detailBl.GetListByKeyword(keyword, page, rowPage, ref total, color, size, sort),
                               PageHtml = search ? Paging.GetPage(pages, 2, page, rowPage, total, "keyword", text) : Paging.GetPage(pages, 2, page, rowPage, total),
            };

            return(PartialView(model));
        }
        public ActionResult Update(string key, string codelogin, string json)
        {
            var msg       = new JsonMessage(false, "Cập nhật dữ liệu thành công.");
            var pictureId = Request["Value_DefaultImages"];

            try
            {
                if (key != Keyapi)
                {
                    return(Json(0, JsonRequestBehavior.AllowGet));
                }
                var model = _da.GetById(ItemId);
                UpdateModel(model);
                model.Description = HttpUtility.UrlDecode(model.Description);
                model.Name        = HttpUtility.UrlDecode(model.Name);
                model.Slug        = FomatString.Slug(model.Name);
                var parent = _da.GetById(model.ParentId ?? 0);
                model.IsLevel = parent.IsLevel + 1;

                model.Price      = model.PriceCost + (model.Profit * model.WeightDefault) * 1000 + model.Incurred;
                model.PriceFinal = model.Price + (model.Percent * model.WeightDefault) * 1000 + model.TotalIncurredFinal;

                _da.Save();
            }
            catch (Exception ex)
            {
                Log2File.LogExceptionToFile(ex);
                msg.Erros   = true;
                msg.Message = "Dữ liệu chưa được cập nhật";
            }
            return(Json(msg, JsonRequestBehavior.AllowGet));
        }
Exemple #5
0
        public PartialViewResult Index(string slug, string url, string tag = "", int pageId = 0, int ctrId = 0, int cateId = 0, int page = 1)
        {
            var       total   = 0;
            const int rowPage = 5;
            var       keyword = "";
            var       text    = "";
            var       search  = slug.Contains("search");
            var       isTag   = tag.Contains("tag");

            if (search)
            {
                text    = Request["keyword"];
                keyword = FomatString.Slug(text);
            }
            var pages = string.Format("/{0}-p{1}c{2}p", slug, pageId, cateId);
            var model = new ModelNewsItem
            {
                ListItem = isTag ? _bl.GetNewByTag(slug, cateId, page, rowPage, ref total)
                    : search?_bl.GetNewKeyword(keyword, page, rowPage, ref total) : _bl.GetList(cateId, page, rowPage, ref total),
                               PageHtml = isTag ? Paging.GetPage("/tag/" + slug + "/", 2, page, rowPage, total) :
                                          !search?Paging.GetPage(pages, 2, page, rowPage, total) :
                                              Paging.GetPage(pages, 2, page, rowPage, total, "keyword", text),
                                              CategoryItem = _productBl.CategoryItem(cateId),
                                              CtrId        = ctrId,
                                              CtrUrl       = url
            };

            return(PartialView(model));
        }
Exemple #6
0
        public IEnumerable <PictureItem> GetListSimpleByRequest(HttpRequestBase httpRequest)
        {
            Request = new ParramRequest(httpRequest);
            var query = from o in FDIDB.Gallery_Picture
                        where o.IsDeleted == false
                        orderby o.DateCreated descending
                        select new PictureItem
            {
                ID          = o.ID,
                Name        = o.Name,
                IsShow      = o.IsShow,
                Description = o.Description,
                DateCreated = o.DateCreated,
                Folder      = o.Folder,
                Url         = o.Folder + o.Url,
                CategoryID  = o.CategoryID,
                //Category = new CategoryItem
                //{
                //    Name = o.Category.Name,
                //    Slug = o.Category.Slug
                //}
            };

            //if (Request.CategoryID > 0)
            //    query = query.Where(o => o.CategoryID == Request.CategoryID);
            if (!string.IsNullOrEmpty(Request.Keyword))
            {
                var name = FomatString.Slug(Request.Keyword);
                query = query.Where(c => c.Name.Contains(name));
            }

            query = query.SelectByRequest(Request, ref TotalRecord);
            return(query.ToList());
        }
        public ActionResult Update(string key, string json, string codelogin, bool isadmin)
        {
            var msg = new JsonMessage(false, "Cập nhật dữ liệu thành công.");

            try
            {
                if (key == Keyapi)
                {
                    var model = _da.GetById(ItemId);
                    UpdateModel(model);
                    if (!isadmin)
                    {
                        model.IsShow = false;
                    }

                    model.Name      = HttpUtility.UrlDecode(model.Name);
                    model.NameAscii = FomatString.Slug(model.Name);
                    _da.Save();
                }
            }
            catch (Exception ex)
            {
                msg.Erros   = true;
                msg.Message = "Dữ liệu chưa được Cập nhật.";
                Log2File.LogExceptionToFile(ex);
            }
            return(Json(msg, JsonRequestBehavior.AllowGet));
        }
Exemple #8
0
        public List <SuggestionsProduct> GetListAutoFull(string keword, int showLimit, int agencyId, int type = 1)
        {
            var name  = FomatString.Slug(keword);
            var date  = DateTime.Now;
            var query = FDIDB.AutoSelectProductFull(name, showLimit).Select(c => new SuggestionsProduct
            {
                ID      = c.ID,
                IsCombo = 0,
                //name = "<span>Mã SP: <b>" + (c.CodeSku ?? "") + "</b> - BarCode:  <b>" + (c.BarCode ?? "") + "</b>- SL:  <b>" + (c.Quantity ?? 0) + "</b> - Màu: <b> " + (c.namecolor ?? "") + "</b> - Size: <b>" + (c.namesize ?? "") + "</b>" + "</span>",
                UrlImg = c.UrlImg ?? "/Content/Admin/images/auto-default.jpg",

                QuantityDay = c.QuantityDay,
                //Quantity = c.Quantity,
                DateS = date.ToString("yyyy-MM-dd"),
                DateE = date.AddMonths(c.QuantityDay ?? 0).ToString("yyyy-MM-dd"),
                code  = c.CodeSku,
                data  = c.PriceNew.ToString(),
                title = c.Name,
                //PriceCost = c.PriceCost,
                pricenew = (decimal)c.PriceNew,
                Type     = type
            });

            return(query.ToList());
        }
Exemple #9
0
        public List <SuggestionsProduct> GetListAutoOne(string keword, int showLimit, int agencyId, int type = 1)
        {
            var name  = FomatString.Slug(keword);
            var query = FDIDB.AutoSelectProductOne(name, showLimit, agencyId).Select(c => new SuggestionsProduct
            {
                ID          = c.ID,
                IsCombo     = 0,
                name        = "<span>BarCode:  <b>" + (c.BarCode ?? "") + "</b>" + "</span>",
                UrlImg      = c.UrlImg ?? "/Content/Admin/images/auto-default.jpg",
                value       = c.BarCode,
                data        = c.PriceNew.ToString(),
                title       = c.Name,
                PriceCost   = c.Price,
                DateS       = c.Date.DecimalToString("dd/MM/yyyy"),
                DateE       = c.DateEnd.DecimalToString("dd/MM/yyyy"),
                Quantity    = 1,
                pricenew    = c.PriceNew,
                Type        = type,
                Idimport    = c.IdImport,
                BarCode     = c.BarCode,
                Valueweight = c.Value
            }).ToList();

            return(query.ToList());
        }
Exemple #10
0
        public List <SuggestionsProduct> GetListAuto(string keword, int showLimit, int agencyId, int type = 1)
        {
            var name  = FomatString.Slug(keword);
            var date  = DateTime.Now;
            var query = FDIDB.AutoSelectProduct(name, showLimit).Select(c => new SuggestionsProduct
            {
                ID          = c.ID,
                IdDetail    = c.IdDetail,
                IsCombo     = 0,
                name        = "<span>BarCode:  <b>" + (c.BarCode ?? "") + "</b>- SL:  <b>" + (c.Quantity ?? 0) + "</b></span>",
                UrlImg      = c.UrlImg ?? "/Content/Admin/images/auto-default.jpg",
                value       = c.BarCode,
                BarCode     = c.BarCode,
                QuantityDay = c.QuantityDay,
                Quantity    = c.Quantity,
                DateS       = date.ToString("yyyy-MM-dd"),
                DateE       = date.AddMonths(c.QuantityDay ?? 0).ToString("yyyy-MM-dd"),
                data        = c.PriceNew.ToString(),
                title       = c.Name,
                pricenew    = c.PriceNew,
                Type        = type,
            });

            return(query.ToList());
        }
Exemple #11
0
        public string CheckByName(string Name, int id)
        {
            var slug   = FomatString.Slug(Name);
            var result = _api.CheckByName(slug, id, UserItem.AgencyID);

            return(result == 1 ? "false" : "true");
        }
        public string CheckTitleAsciiExits(string Title, int id)
        {
            var ascii  = FomatString.Slug(Title);
            var result = _newsDa.CheckTitleAsciiExits(ascii, id);

            return(result ? "false" : "true");
        }
 public DN_Roles UpdateRole(DN_Roles activeRole, DNRolesJsonItem activeRoleItem)
 {
     activeRole.RoleName        = activeRoleItem.RoleName;
     activeRole.Description     = activeRoleItem.Description;
     activeRole.LoweredRoleName = FomatString.Slug(activeRole.RoleName);
     activeRole.LevelId         = activeRoleItem.LevelRoomId;
     activeRole.IsDeleted       = false;
     return(activeRole);
 }
        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 UploadFiles()
        {
            string[] lst = new string[] { "jpg", "png" };

            var item      = new FileObj();
            var urlFolder = ConfigData.TempFolder;

            if (!Directory.Exists(urlFolder))
            {
                Directory.CreateDirectory(urlFolder);
            }
            foreach (string file in Request.Files)
            {
                var hpf          = Request.Files[file];
                var fileNameRoot = hpf != null ? hpf.FileName : string.Empty;
                if (hpf != null && hpf.ContentLength == 0)
                {
                    continue;
                }
                if (hpf != null)
                {
                    if (fileNameRoot.Length > 1)
                    {
                        var fileLocal = fileNameRoot.Split('.');
                        if (!lst.Contains(fileLocal[1].ToLower()))
                        {
                            item.Error = true;
                            continue;
                        }
                        var fileName      = FomatString.Slug(fileLocal[0]) + "-" + DateTime.Now.ToString("MMddHHmmss") + "." + fileLocal[1];
                        var savedFileName = Path.Combine((urlFolder), Path.GetFileName(fileName));
                        hpf.SaveAs(savedFileName);
                        item = new FileObj
                        {
                            Name     = fileName,
                            NameRoot = fileLocal[0],
                            Forder   = ConfigData.Temp,
                            Icon     = "/Images/Icons/file/" + fileLocal[1] + ".png",
                            Error    = false
                        };
                    }
                }
            }
            return(Json(item));
        }
Exemple #16
0
        public List <SuggestionsProduct> GetListAutoProductValue(string keword, int showLimit, int agencyId, int type = 1)
        {
            var name  = FomatString.Slug(keword);
            var date  = DateTime.Now;
            var query = FDIDB.AutoSelectCateValueFull(name, showLimit, type).Select(c => new SuggestionsProduct
            {
                ID       = c.ID,
                name     = "<span>Giá bán: <b>" + (c.Price.Money()) + "</b> " + "</span>" + "<span>Đơn vị: <b>Con</b> " + "</span>",
                UrlImg   = c.UrlImg ?? "/Content/Admin/images/auto-default.jpg",
                data     = c.Price.ToString(),
                Unit     = "Con",
                title    = c.Name,
                pricenew = c.Price,
                Type     = type
            }).ToList();

            return(query.ToList());
        }
 public ActionResult Update(string key, string json)
 {
     try
     {
         if (key != Keyapi)
         {
             return(Json(0, JsonRequestBehavior.AllowGet));
         }
         var model = _da.GetById(ItemId);
         UpdateModel(model);
         model.Name      = HttpUtility.UrlDecode(model.Name);
         model.NameAscii = FomatString.Slug(model.Name);
         _da.Save();
         return(Json(1, JsonRequestBehavior.AllowGet));
     }
     catch (Exception)
     {
         return(Json(0, JsonRequestBehavior.AllowGet));
     }
 }
Exemple #18
0
        public List <SuggestionsProduct> GetListCommentAuto(string keword, int showLimit, int agencyId)
        {
            var name  = FomatString.Slug(keword);
            var query = from c in FDIDB.Shop_Product
                        where (!c.IsDelete.HasValue || c.IsDelete == false) && !string.IsNullOrEmpty(c.Shop_Product_Detail.Code) && c.IsShow == true &&
                        (c.Shop_Product_Detail.NameAscii.Contains(name) || c.Shop_Product_Detail.Code.ToLower().Contains(name))
                        select new SuggestionsProduct
            {
                ID       = c.ID,
                IsCombo  = 0,
                value    = c.Shop_Product_Detail.Code + " - " + c.Shop_Product_Detail.Name,
                title    = c.Shop_Product_Detail.Name,
                data     = "Giá: " + SqlFunctions.StringConvert(c.Shop_Product_Detail.Price * (c.Product_Size == null ? 1000 : (decimal)c.Product_Size.Value) / 1000),
                name     = "",
                Color    = c.System_Color.Name ?? "",
                Size     = c.Product_Size.Name ?? "",
                pricenew = c.Shop_Product_Detail.Price * (c.Product_Size == null ? 1000 : (decimal)c.Product_Size.Value) / 1000,
                Unit     = c.Shop_Product_Detail.DN_Unit.Name ?? "",
            };

            return(query.Take(showLimit).ToList());
        }
Exemple #19
0
        public List <SuggestionsProduct> GetListAutoComplete(string keword, int showLimit, int agencyId, int type = 0)
        {
            var name  = FomatString.Slug(keword);
            var query = from c in FDIDB.Shop_Product
                        where (!c.IsDelete.HasValue || c.IsDelete == false) && !string.IsNullOrEmpty(c.Shop_Product_Detail.Code) && c.IsShow == true &&
                        (c.Shop_Product_Detail.NameAscii.Contains(name) || c.CodeSku.ToLower().Contains(name))
                        select new SuggestionsProduct
            {
                ID          = c.ID,
                IsCombo     = 0,
                value       = c.CodeSku,
                QuantityDay = c.QuantityDay ?? 0,
                title       = c.Shop_Product_Detail.Name,
                data        = "Giá: " + SqlFunctions.StringConvert(c.Shop_Product_Detail.Price * (c.Product_Size == null ? 1000 : (decimal)c.Product_Size.Value) / 1000),
                name        = "Mã SP: " + c.CodeSku,
                pricenew    = c.Shop_Product_Detail.Price * (c.Product_Size == null ? 1000 : (decimal)c.Product_Size.Value) / 1000,
                Unit        = c.Shop_Product_Detail.DN_Unit.Name,
                Type        = type
            };

            return(query.ToList());
        }
        public ContentResult UploadFiles()
        {
            var fileObj = new List <FileObj>();

            foreach (string file in Request.Files)
            {
                var hpf          = Request.Files[file];
                var fileNameRoot = hpf != null ? hpf.FileName : string.Empty;
                if (hpf != null && hpf.ContentLength == 0)
                {
                    continue;
                }

                if (hpf != null)
                {
                    var urlFolder = ConfigData.MailFolder;
                    if (!Directory.Exists(urlFolder))
                    {
                        Directory.CreateDirectory(urlFolder);
                    }
                    if (fileNameRoot.Length > 1)
                    {
                        var fileLocal     = fileNameRoot.Split('.');
                        var fileName      = FomatString.Slug(fileLocal[0]) + "-" + DateTime.Now.ToString("yyyyMMddHHmmss") + "." + fileLocal[1];
                        var savedFileName = Path.Combine((urlFolder), Path.GetFileName(fileName));
                        hpf.SaveAs(savedFileName);
                        fileObj.Add(new FileObj()
                        {
                            Name = fileName,
                            Size = hpf.ContentLength,
                            Type = hpf.ContentType
                        });
                    }
                }
            }
            return(Content("{\"name\":\"" + fileObj[0].Name + "\",\"type\":\"" + fileObj[0].Type + "\",\"size\":\"" + string.Format("{0} bytes", fileObj[0].Size) + "\"}", "application/json"));
        }
Exemple #21
0
        public List <SuggestionsProduct> GetListAuto(string keword, int showLimit, int agencyId, int type = 0)
        {
            keword = FomatString.Slug(keword);
            var query = from c in FDIDB.DN_Import
                        where c.Shop_Product_Value.NameAscii.Contains(keword) &&
                        c.Shop_Product_Value.AgencyId == agencyId && c.IsDelete == false && c.Shop_Product_Value.IsDeleted == false && c.Storage.IsDelete == false && c.Quantity > 0
                        select new SuggestionsProduct
            {
                ID          = c.ID,
                value       = c.Shop_Product_Value.NameAscii,
                title       = c.Shop_Product_Value.Name,
                code        = c.Shop_Product_Value.Code,
                QuantityDay = c.Shop_Product_Value.QuantityDay ?? 0,
                Quantity    = c.Quantity,
                QuantityOut = c.Export_Product_Value.Where(u => u.IsDelete == false).Sum(u => u.Quantity ?? 0),
                Date        = c.Storage.DateImport,
                DateEnd     = c.DateEnd,
                Unit        = c.Shop_Product_Value.DN_Unit.Name,
                Type        = type,
                pricenew    = c.Price
            };

            return(query.Take(showLimit).ToList());
        }
Exemple #22
0
        public ActionResult Actions()
        {
            var            msg     = new JsonMessage();
            var            partner = new Partner();
            List <Partner> ltsPartner;
            StringBuilder  stbMessage;
            List <int>     idValues;
            var            images    = Request["Value_Images"];
            var            lstimages = Request["Value_ImagesProducts"];

            switch (Action)
            {
            case ActionType.Add:
                try
                {
                    UpdateModel(partner);
                    partner.Name           = partner.Name.RemoveHTML();
                    partner.Description    = partner.Description.RemoveHTML();
                    partner.Description    = partner.Description.RemoveHTML();
                    partner.SEODescription = partner.SEODescription.RemoveHTML();
                    partner.SEOKeyword     = partner.SEOKeyword.RemoveHTML();

                    partner.LanguageId  = Fdisystem.LanguageId;
                    partner.Slug        = FomatString.Slug(partner.Name);
                    partner.DateCreated = DateTime.Now;
                    if (!string.IsNullOrEmpty(images))
                    {
                        partner.PictureID = Convert.ToInt32(images);
                    }
                    if (!string.IsNullOrEmpty(lstimages))
                    {
                        var lstInt = FDIUtils.StringToListInt(lstimages);
                        partner.Gallery_Picture1 = _da.GetListPictureByArrId(lstInt);
                    }

                    partner.IsDeleted = false;
                    _da.Add(partner);
                    _da.Save();
                    msg = new JsonMessage
                    {
                        Erros   = false,
                        ID      = partner.ID.ToString(),
                        Message = string.Format("Đã thêm mới bài viết: <b>{0}</b>", Server.HtmlEncode(partner.Name))
                    };
                }
                catch (Exception ex)
                {
                    LogHelper.Instance.LogError(GetType(), ex);
                }

                break;

            case ActionType.Edit:
                try
                {
                    partner = _da.GetById(ArrId.FirstOrDefault());
                    UpdateModel(partner);
                    partner.Name           = partner.Name.RemoveHTML();
                    partner.Description    = partner.Description.RemoveHTML();
                    partner.Description    = partner.Description.RemoveHTML();
                    partner.SEODescription = partner.SEODescription.RemoveHTML();
                    partner.SEOKeyword     = partner.SEOKeyword.RemoveHTML();
                    if (!string.IsNullOrEmpty(images))
                    {
                        partner.PictureID = Convert.ToInt32(images);
                    }
                    partner.Gallery_Picture1.Clear();
                    if (!string.IsNullOrEmpty(lstimages))
                    {
                        var lstInt = FDIUtils.StringToListInt(lstimages);
                        partner.Gallery_Picture1 = _da.GetListPictureByArrId(lstInt);
                    }
                    _da.Save();
                    msg = new JsonMessage
                    {
                        Erros   = false,
                        ID      = partner.ID.ToString(),
                        Message = string.Format("Đã cập nhật bài viết: <b>{0}</b>", Server.HtmlEncode(partner.Name))
                    };
                }
                catch (Exception ex)
                {
                    LogHelper.Instance.LogError(GetType(), ex);
                }

                break;

            case ActionType.Delete:
                ltsPartner = _da.GetListByArrId(ArrId);
                stbMessage = new StringBuilder();
                foreach (var item in ltsPartner)
                {
                    try
                    {
                        item.IsDeleted = true;
                        stbMessage.AppendFormat("Đã xóa bài viết <b>{0}</b>.<br />", Server.HtmlEncode(item.Name));
                        _da.Save();
                    }
                    catch (Exception ex)
                    {
                        LogHelper.Instance.LogError(GetType(), ex);
                    }
                }
                msg.ID = string.Join(",", ArrId);
                _da.Save();
                msg.Message = stbMessage.ToString();
                break;

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

            case ActionType.Hide:
                ltsPartner = _da.GetListByArrId(ArrId);
                stbMessage = new StringBuilder();
                foreach (var item in ltsPartner)
                {
                    item.IsShow = false;
                    stbMessage.AppendFormat("Đã ẩn bài viết <b>{0}</b>.<br />", Server.HtmlEncode(item.Name));
                }
                _da.Save();
                msg.ID      = string.Join(",", ltsPartner.Select(o => o.ID));
                msg.Message = stbMessage.ToString();
                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));
        }
        public ActionResult AjaxFormPictureSubmit()
        {
            var date = DateTime.Now;
            var msg  = new JsonMessage {
                Erros = false
            };
            var intTotalFile = Convert.ToInt32(Request["NumberOfImage"]);
            var folder       = date.Year + "\\" + date.Month + "\\" + date.Day + "\\";
            var fileinsert   = date.Year + "/" + date.Month + "/" + date.Day + "/";
            var folderinsert = fileinsert;

            for (var idx = 0; idx < intTotalFile; idx++)
            {
                var fileNameLocal = Request["ImageFile_" + idx + ""];
                var file          = fileNameLocal.Split('.');
                var nameslug      = FomatString.Slug(file[0]);
                var fileName      = nameslug + "-" + date.ToString("HHmmss") + "." + file[1];
                if (!nameslug.Contains(ConfigData.WebTitle))
                {
                    fileName = ConfigData.WebTitle + nameslug + "-" + date.ToString("HHmmss") + "." + file[1];
                }

                var fileTemp    = nameslug + "." + file[1];
                var imageSource = Image.FromFile(ConfigData.TempFolder + fileTemp);
                var checkfolder = false;
                if (Request["ckImage_" + (int)FolderImage.Originals] != null)
                {
                    checkfolder = true;
                    ImageProcess.CreateForder(ConfigData.OriginalFolder); // tạo forder Năm / Tháng / Ngày
                    if (imageSource.Width > ConfigData.ImageFullHdFile.Width)
                    {
                        var image = ImageProcess.ResizeImage(imageSource, ConfigData.ImageFullHdFile);
                        ImageProcess.SaveJpeg(ConfigData.OriginalFolder + folder + fileName, new Bitmap(image), 92L); // Save file Original
                    }
                    else
                    {
                        System.IO.File.Copy(ConfigData.TempFolder + fileTemp, ConfigData.OriginalFolder + folder + fileName);
                    }
                    folderinsert = "Originals/" + fileinsert;
                }

                if (Request["ckImage_" + (int)FolderImage.Images] != null)
                {
                    checkfolder = true;
                    ImageProcess.CreateForder(ConfigData.ImageFolder); // tạo forder Năm / Tháng / Ngày
                    if (imageSource.Width > ConfigData.ImageHdFile.Width)
                    {
                        var image = ImageProcess.ResizeImage(imageSource, ConfigData.ImageHdFile);
                        ImageProcess.SaveJpeg(ConfigData.ImageFolder + folder + fileName, new Bitmap(image), 92L); // Save file Images
                    }
                    else
                    {
                        System.IO.File.Copy(ConfigData.TempFolder + fileTemp, ConfigData.ImageFolder + folder + fileName);
                    }
                    folderinsert = "Images/" + fileinsert;
                }

                //Resize ảnh 640
                if (Request["ckImage_" + (int)FolderImage.Mediums] != null)
                {
                    checkfolder = true;
                    ImageProcess.CreateForder(ConfigData.ImageUploadMediumFolder); // tạo forder Năm / Tháng / Ngày
                    if (imageSource.Width > ConfigData.ImageMediumFile.Width)
                    {
                        var image = ImageProcess.ResizeImage(imageSource, ConfigData.ImageFullHdFile);
                        ImageProcess.SaveJpeg(ConfigData.ImageUploadMediumFolder + folder + fileName, new Bitmap(image), 92L); // Save file Medium
                    }
                    else
                    {
                        System.IO.File.Copy(ConfigData.TempFolder + fileTemp, ConfigData.ImageUploadMediumFolder + folder + fileName);
                    }
                    folderinsert = "Mediums/" + fileinsert;
                }

                if (!checkfolder)
                {
                    folderinsert = "Thumbs/" + fileinsert;
                }

                if (Request["ckImage_" + (int)FolderImage.Thumbs] != null)
                {
                    ImageProcess.CreateForder(ConfigData.ThumbsFolder);
                }

                if (imageSource.Width < ConfigData.ImageThumbsSize.Width)
                {
                    ImageProcess.SaveJpeg(ConfigData.ThumbsFolder + folder + fileName, new Bitmap(imageSource), 92L); // Save file Thumbs
                }
                else
                {
                    imageSource = ImageProcess.ResizeImage(imageSource, ConfigData.ImageThumbsSize);
                    ImageProcess.SaveJpeg(ConfigData.ThumbsFolder + folder + fileName, new Bitmap(imageSource), 92L); // Save file Thumbs
                }
                imageSource.Dispose();
                //Lấy thông tin cần thiết
                var picture = new Gallery_Picture
                {
                    Type = !string.IsNullOrEmpty(Request["type"]) ? Convert.ToInt32(Request["type"]) : 0,
                    //CategoryID =
                    //    !string.IsNullOrEmpty(Request["CategoryID"]) ? Convert.ToInt32(Request["CategoryID"]) : 1,
                    LanguageId  = Fdisystem.LanguageId,
                    DateCreated = date.TotalSeconds(),
                    Folder      = folderinsert,
                    Name        = Request["ImageName_" + idx],
                    IsShow      = true,
                    Url         = fileName,
                    IsDeleted   = false,
                    CreateBy    = User.Identity.Name,
                    UpdateBy    = User.Identity.Name
                };
                _pictureDa.Add(picture);
                msg.Message += string.Format("Đã thêm hình ảnh: <b>{0}</b><br/>", picture.Name);
            }
            _pictureDa.Save();
            return(Json(msg, JsonRequestBehavior.AllowGet));
        }
Exemple #24
0
        public ActionResult Actions()
        {
            var msg         = new JsonMessage();
            var mailSscItem = new DNGroupMailSSCItem();
            List <DNGroupMailSSCItem> ltsDnMailSscItem;
            var json  = "";
            var lstId = Request["itemId"];

            switch (DoAction)
            {
            case ActionType.Add:
                try
                {
                    UpdateModel(mailSscItem);
                    mailSscItem.DateCreated = ConvertDate.TotalSeconds(DateTime.Now);
                    mailSscItem.LstUserIds  = Request["UserId"];
                    mailSscItem.Slug        = FomatString.Slug(mailSscItem.Name);
                    json = new JavaScriptSerializer().Serialize(mailSscItem);
                    _dnMailSscapi.Add(UserItem.AgencyID, json);
                    msg = new JsonMessage
                    {
                        Erros   = false,
                        ID      = mailSscItem.ID.ToString(),
                        Message = string.Format("Đã thêm mới hành động: <b>{0}</b>", Server.HtmlEncode(mailSscItem.Name))
                    };
                }
                catch (Exception ex)
                {
                    LogHelper.Instance.LogError(GetType(), ex);
                }
                break;

            case ActionType.Edit:
                try
                {
                    UpdateModel(mailSscItem);
                    mailSscItem.LstUserIds = Request["UserId"];
                    mailSscItem.Slug       = FomatString.Slug(mailSscItem.Name);
                    json = new JavaScriptSerializer().Serialize(mailSscItem);
                    _dnMailSscapi.Update(UserItem.AgencyID, json, ArrId.FirstOrDefault());

                    msg = new JsonMessage
                    {
                        Erros   = false,
                        ID      = mailSscItem.ID.ToString(),
                        Message = string.Format("Đã cập nhật : <b>{0}</b>", Server.HtmlEncode(mailSscItem.Name))
                    };
                }
                catch (Exception ex)
                {
                    LogHelper.Instance.LogError(GetType(), ex);
                }
                break;

            case ActionType.Delete:
                ltsDnMailSscItem = _dnMailSscapi.GetListByArrId(UserItem.AgencyID, lstId);
                foreach (var item in ltsDnMailSscItem)
                {
                    UpdateModel(item);
                    json = new JavaScriptSerializer().Serialize(item);
                    _dnMailSscapi.Update(UserItem.AgencyID, json, item.ID);
                }
                msg = new JsonMessage
                {
                    Erros   = false,
                    ID      = mailSscItem.ID.ToString(),
                    Message = string.Format("Đã cập nhật : <b>{0}</b>", Server.HtmlEncode(string.Join(", ", ltsDnMailSscItem.Select(c => c.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));
        }
Exemple #25
0
        public ActionResult Actions()
        {
            var msg = new JsonMessage();
            var tag = new System_Tag();
            List <System_Tag> ltsTagItems;
            StringBuilder     stbMessage;

            switch (DoAction)
            {
            case ActionType.Add:
                UpdateModel(tag);
                tag.LanguageId = Fdisystem.LanguageId;
                tag.NameAscii  = FomatString.Slug(tag.Name);
                tag.IsDelete   = false;
                tag.IsShow     = true;
                _tagDa.Add(tag);
                _tagDa.Save();
                msg = new JsonMessage
                {
                    Erros   = false,
                    ID      = tag.ID.ToString(),
                    Message = string.Format("Đã thêm mới từ khóa: <b>{0}</b>", Server.HtmlEncode(tag.Name))
                };
                break;

            case ActionType.Edit:
                tag = _tagDa.GetById(ArrId.FirstOrDefault());
                UpdateModel(tag);
                tag.NameAscii = FomatString.Slug(tag.Name);
                _tagDa.Save();
                msg = new JsonMessage
                {
                    Erros   = false,
                    ID      = tag.ID.ToString(),
                    Message = string.Format("Đã cập nhật từ khóa: <b>{0}</b>", Server.HtmlEncode(tag.Name))
                };
                break;

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

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

            case ActionType.Hide:
                ltsTagItems = _tagDa.GetListByArrId(ArrId);
                stbMessage  = new StringBuilder();
                foreach (var item in ltsTagItems)
                {
                    item.IsShow = false;
                    stbMessage.AppendFormat("Đã ẩn từ khóa <b>{0}</b>.<br />", Server.HtmlEncode(item.Name));
                }
                _tagDa.Save();
                msg.ID      = string.Join(",", ltsTagItems.Select(o => o.ID));
                msg.Message = stbMessage.ToString();
                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));
        }