Ejemplo n.º 1
0
        public ActionResult ShowHide(string key, string lstArrId, bool showhide)
        {
            var msg = new JsonMessage(false, "Cập nhật dữ liệu thành công.");

            try
            {
                var lstInt = FDIUtils.StringToListInt(lstArrId);
                var lst    = _da.GetListArrId(lstInt);
                foreach (var item in lst)
                {
                    item.IsShow = showhide;
                }
                _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));
        }
Ejemplo n.º 2
0
 public ActionResult Active(string key, Guid userId, string lstArrId)
 {
     try
     {
         if (key != Keyapi)
         {
             return(Json(0, JsonRequestBehavior.AllowGet));
         }
         var lstInt = FDIUtils.StringToListInt(lstArrId);
         var model  = _da.GetListByArrId(lstInt);
         foreach (var item in model)
         {
             item.Status       = true;
             item.DateApproval = DateTime.Now.TotalSeconds();
         }
         _da.Save();
         return(Json(1, JsonRequestBehavior.AllowGet));
     }
     catch (Exception)
     {
         return(Json(0, JsonRequestBehavior.AllowGet));
     }
 }
Ejemplo n.º 3
0
        public ActionResult Delete(string key, string lstArrId)
        {
            var msg = new JsonMessage(false, "Xóa dữ liệu thành công !");

            try
            {
                if (key == Keyapi)
                {
                    var lstInt = FDIUtils.StringToListInt(lstArrId);
                    var lst    = _da.GetListArrId(lstInt);
                    foreach (var item in lst)
                    {
                        item.IsDeleted = true;
                    }
                    _da.Save();
                }
            }
            catch (Exception ex)
            {
                msg.Erros   = true;
                msg.Message = "Dữ liệu chưa được xóa.";
            }
            return(Json(msg, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 4
0
        public ActionResult AddCustomer(string key, string code)
        {
            if (key == Keyapi)
            {
                string url     = "Utility/GetContentEmail?key=" + code;
                var    urlJson = string.Format("{0}", UrlCustomer + url);
                var    email   = Utility.GetObjJson <DNMailSSCItem>(urlJson);
                email.AgencyID = Agencyid();
                if (email.ListUserReceiveIds != null)
                {
                    // insert file đính kèm
                    var lstImage = email.ListUrlPicture.Split(',');
                    var listfile = lstImage.Select(item => new DN_File_Mail
                    {
                        IsShow      = true,
                        IsDeleted   = false,
                        DateCreated = DateTime.Now,
                        Url         = item,
                        Name        = item,
                        Folder      = "/Uploads/Mail/",
                        AgencyId    = Agencyid()
                    }).ToList();
                    foreach (var item in listfile)
                    {
                        _mailBl.Add(item);
                    }
                    _mailBl.Save();

                    var strId = string.Join(",", listfile.Select(m => m.ID));
                    var list  = new List <DN_Mail_SSC>();
                    _mailBl.Save();

                    var lstId = FDIUtils.StringToListInt(email.ListUserReceiveIds);
                    // người gửi

                    foreach (var item in lstId)
                    {
                        var obj1 = new DN_Mail_SSC();
                        email.CustomerReceiveId = item;
                        email.StatusEmail       = true;
                        UpdateBase(obj1, email);
                        list.Add(obj1);
                        _dnMailSscda.Add(obj1);

                        var obj2 = new DN_Mail_SSC();
                        email.CustomerReceiveId = item;
                        email.StatusEmail       = false;
                        UpdateBase(obj2, email);
                        list.Add(obj2);
                        _dnMailSscda.Add(obj2);
                    }

                    var check1 = true;
                    foreach (var item in list)
                    {
                        if (check1)
                        {
                            check1 = false;
                            var lstFileMail = _dnMailSscda.GetFileMailArrId(strId);
                            foreach (var itemf in lstFileMail)
                            {
                                item.DN_File_Mail.Add(itemf);
                            }
                        }
                        _dnMailSscda.Add(item);
                    }

                    _dnMailSscda.Save();

                    // bảng status
                    foreach (var item in list)
                    {
                        var objStatus1 = new DN_StatusEmail
                        {
                            CustomerId = item.StatusEmail == true ? item.CustomerSendId : item.CustomerReceiveId,
                            Status     = item.StatusEmail,
                            MailId     = item.ID
                        };
                        _dnMailStatusDa.Add(objStatus1);
                    }
                    _dnMailStatusDa.Save();

                    return(Json(1, JsonRequestBehavior.AllowGet));
                }
                return(Json(0, JsonRequestBehavior.AllowGet));
            }
            return(Json(0, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 5
0
        public ActionResult Actions()
        {
            var msg      = new JsonMessage(false, "Cập nhật dữ liệu thành công");
            var model    = new DN_OrderCard();
            var itemCard = new DN_Card();

            switch (DoAction)
            {
            case ActionType.Add:
                try
                {
                    var number = int.Parse(Request["numberCard"]);
                    var date   = DateTime.Now.ToString("yyMMdd");
                    model.Code = int.Parse(date);
                    var       count  = _da.Count(model.Code);
                    const int status = (int)Card.Create;
                    UpdateModel(model);
                    for (var i = 1; i <= number; i++)
                    {
                        var item = new DN_Card
                        {
                            Code     = Guid.NewGuid().ToString("N").ToUpper(),
                            Serial   = FDIUtils.RandomMaKh(date, count + i, 6),
                            PinCard  = FDIUtils.RandomKey(9),
                            IsActive = false,
                            Status   = status
                        };
                        model.DN_Card.Add(item);
                    }
                    model.DateCreate = ConvertDate.TotalSeconds(DateTime.Now);
                    _da.Add(model);
                    _da.Save();
                }
                catch (Exception ex)
                {
                    msg.Erros   = true;
                    msg.Message = "Dữ liệu chưa được cập nhật.";
                }
                break;

            case ActionType.Order:
                try
                {
                    var sendcarditem = new Send_Card();
                    UpdateModel(sendcarditem);
                    var customerid = Request["CustomerID"];
                    var lstSerial  = Request["LstSerial"];
                    var lstInt     = FDIUtils.StringToListInt(lstSerial);
                    foreach (var i in lstInt)
                    {
                        _sendCardDa.Add(new Send_Card
                        {
                            CustomerID = int.Parse(customerid),
                            //CardID = i,
                            DateCreate = ConvertDate.TotalSeconds(DateTime.Now)
                        });
                    }
                    _sendCardDa.Save();
                }
                catch (Exception ex)
                {
                    msg.Erros   = true;
                    msg.Message = "Dữ liệu chưa được cập nhật.";
                }
                break;

            case ActionType.Active:
                try
                {
                    var firstCard = Request["firstCard"];
                    var oldCard   = Request["oldCard"];
                    var status    = Request["Status"];
                    var lst       = _da.UpdateCard(firstCard, oldCard);

                    if (lst != null && !string.IsNullOrEmpty(status))
                    {
                        var t = int.Parse(status);
                        foreach (var item in lst)
                        {
                            item.Status = t;
                        }
                    }
                    _da.Save();
                }
                catch (Exception ex)
                {
                    msg.Erros   = true;
                    msg.Message = "Dữ liệu chưa được cập nhật.";
                }
                break;

            case ActionType.Show:
                try
                {
                    var lstCard = _da.GetById(ArrId);
                    foreach (var item in lstCard)
                    {
                        item.Status = (int)Card.Released;
                    }
                    _da.Save();
                    msg = new JsonMessage
                    {
                        Erros   = false,
                        ID      = model.ID.ToString(),
                        Message = "Thẻ đã được mở thành công"
                    };
                }
                catch (Exception ex)
                {
                    msg.Erros   = true;
                    msg.Message = "Dữ liệu chưa được cập nhật.";
                }
                break;

            case ActionType.Hide:
                try
                {
                    var lstCard = _da.GetById(ArrId);
                    foreach (var item in lstCard)
                    {
                        item.Status = (int)Card.Lock;
                    }
                    _da.Save();
                }
                catch (Exception ex)
                {
                    msg.Erros   = true;
                    msg.Message = "Dữ liệu chưa được cập nhật.";
                }
                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));
        }
Ejemplo n.º 6
0
        public List <ShopProductDetailItem> GetListBykeyword(string keyword, int page, int rowPage, ref int total, string color, string size, string sort)
        {
            var query = from n in FDIDB.Shop_Product_Detail
                        where n.IsDelete == false && n.IsShow == true &&
                        n.NameAscii.Contains(keyword)
                        orderby n.ID descending
                        select new ShopProductDetailItem
            {
                ID              = n.ID,
                Name            = n.Name,
                NameAscii       = n.NameAscii,
                Sale            = n.Sale,
                UrlPicture      = n.Gallery_Picture.IsDeleted != true ? n.Gallery_Picture.Folder + n.Gallery_Picture.Url : "",
                UrlPictureMap   = n.Gallery_Picture1.IsDeleted != true ? n.Gallery_Picture1.Folder + n.Gallery_Picture1.Url : "",
                Description     = n.Description,
                ListProductItem = n.Shop_Product.Where(c => c.IsDelete != true).Select(v => new ProductItem
                {
                    ID       = v.ID,
                    PriceNew = (v.Shop_Product_Detail.Price * (decimal)v.Product_Size.Value / 1000) ?? 0,
                    //PriceOld = v.PriceOld
                }),
                //ListColorProductItem = from a in n.Shop_Product
                //                       group a by a.ColorID into g
                //                       select new ColorItem
                //                       {
                //                           ID = g.FirstOrDefault().System_Color.ID,
                //                           Name = g.FirstOrDefault().System_Color.Name,
                //                           Value = g.FirstOrDefault().System_Color.Value
                //                       },
                ListSizeProductItem = from a in n.Shop_Product
                                      group a by a.SizeID into g
                                      select new ProductSizeItem
                {
                    ID    = g.FirstOrDefault().Product_Size.ID,
                    Name  = g.FirstOrDefault().Product_Size.Name,
                    Value = g.FirstOrDefault().Product_Size.Value
                }
            };

            if (!string.IsNullOrEmpty(color))
            {
                var lstArr = FDIUtils.StringToListInt(color);

                query = query.Where(c => c.ListColorProductItem.Any(a => lstArr.Contains(a.ID)));
            }
            if (!string.IsNullOrEmpty(size))
            {
                var lstArr = FDIUtils.StringToListInt(size);
                query = query.Where(c => c.ListSizeProductItem.Any(a => lstArr.Contains(a.ID)));
            }
            if (!string.IsNullOrEmpty(sort))
            {
                if (sort == "az")
                {
                    query = query.OrderBy(c => c.Name);
                }
                if (sort == "za")
                {
                    query = query.OrderByDescending(c => c.Name);
                }
                if (sort == "lh")
                {
                    query = query.OrderBy(c => c.ListProductItem.Select(a => a.PriceNew).FirstOrDefault());
                }
                if (sort == "hl")
                {
                    query = query.OrderByDescending(c => c.ListProductItem.Select(a => a.PriceNew).FirstOrDefault());
                }
            }
            query = query.Paging(page, rowPage, ref total);
            return(query.ToList());
        }
Ejemplo n.º 7
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));
        }
Ejemplo n.º 8
0
        public ActionResult Actions()
        {
            var msg    = new JsonMessage();
            var module = new DN_Module();
            List <DN_Module> ltsModuleItems;
            StringBuilder    stbMessage;
            var list = Request["GroupId"];

            switch (DoAction)
            {
            case ActionType.Add:
                try
                {
                    UpdateModel(module);
                    module.IsDelete = false;
                    _moduleDa.Add(module);
                    module.ST_Group = _moduleDa.ListST_GroupByArrID(FDIUtils.StringToListInt(list));
                    _moduleDa.Save();
                    if (module.IsAll == true)
                    {
                        _moduleDa.AddItemByIAll(module.ID, list);
                    }
                    msg = new JsonMessage
                    {
                        Erros   = false,
                        ID      = module.ID.ToString(),
                        Message = string.Format("Đã thêm mới: <b>{0}</b>", Server.HtmlEncode(module.NameModule))
                    };
                }
                catch (Exception ex)
                {
                    LogHelper.Instance.LogError(GetType(), ex);
                }
                break;

            case ActionType.Edit:
                try
                {
                    module = _moduleDa.GetById(ArrId.FirstOrDefault());
                    UpdateModel(module);
                    module.ST_Group.Clear();
                    module.ST_Group = _moduleDa.ListST_GroupByArrID(FDIUtils.StringToListInt(list));
                    _moduleDa.Save();
                    if (module.IsAll == true)
                    {
                        _moduleDa.AddItemByIAll(module.ID, list);
                    }
                    else
                    {
                        _moduleDa.DeleteItemByIAll(module.ID, list);
                    }
                    msg = new JsonMessage
                    {
                        Erros   = false,
                        ID      = module.ID.ToString(),
                        Message = string.Format("Đã cập nhật : <b>{0}</b>", Server.HtmlEncode(module.NameModule))
                    };
                }
                catch (Exception ex)
                {
                    LogHelper.Instance.LogError(GetType(), ex);
                }
                break;


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

            case ActionType.Show:
                ltsModuleItems = _moduleDa.GetListByArrID(ArrId).Where(o => o.IsShow != true).ToList();     //Chỉ lấy những đối tượng ko được hiển thị
                stbMessage     = new StringBuilder();
                foreach (var item in ltsModuleItems)
                {
                    item.IsShow = true;
                    stbMessage.AppendFormat("Đã hiển thị <b>{0}</b>.<br />", Server.HtmlEncode(item.NameModule));
                }
                _moduleDa.Save();
                msg.ID      = string.Join(",", ltsModuleItems.Select(o => o.ID));
                msg.Message = stbMessage.ToString();
                break;

            case ActionType.Hide:
                ltsModuleItems = _moduleDa.GetListByArrID(ArrId).Where(o => o.IsShow == true).ToList();     //Chỉ lấy những đối tượng được hiển thị
                stbMessage     = new StringBuilder();
                foreach (var item in ltsModuleItems)
                {
                    item.IsShow = false;
                    stbMessage.AppendFormat("Đã ẩn <b>{0}</b>.<br />", Server.HtmlEncode(item.NameModule));
                }
                _moduleDa.Save();
                msg.ID      = string.Join(",", ltsModuleItems.Select(o => o.ID));
                msg.Message = stbMessage.ToString();
                break;

            case ActionType.Order:
                if (!string.IsNullOrEmpty(Request["OrderValues"]))
                {
                    var orderValues = Request["OrderValues"];
                    if (orderValues.Contains("|"))
                    {
                        foreach (var keyValue in orderValues.Split('|'))
                        {
                            if (keyValue.Contains("_"))
                            {
                                var tempCategory = _moduleDa.GetById(Convert.ToInt32(keyValue.Split('_')[0]));
                                tempCategory.Ord = Convert.ToInt32(keyValue.Split('_')[1]);
                                _moduleDa.Save();
                            }
                        }
                    }
                    msg.ID      = string.Join(",", orderValues);
                    msg.Message = "Đã cập nhật lại thứ tự ";
                }
                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));
        }
Ejemplo n.º 9
0
        public ActionResult Actions()
        {
            var msg   = new JsonMessage();
            var model = new News_News();
            List <News_News> ltsNewsItems;
            StringBuilder    stbMessage;
            List <Category>  lstCategory;
            var lsttag     = Request["values-arr-tag"];
            var images     = Request["Value_DefaultImages"];
            var lstCate    = Request["Value_CategoryValues"];
            var datecreate = Request["DateCreated_"];

            switch (DoAction)
            {
            case ActionType.Add:
                try
                {
                    UpdateModel(model);
                    model.LanguageId = Fdisystem.LanguageId;
                    //model.Viewer = 0;
                    var membershipUser = Membership.GetUser();
                    //model.TitleAscii = FomatString.Slug(model.Title);

                    if (membershipUser != null)
                    {
                        model.Author = membershipUser.UserName;
                    }
                    model.DateCreated = !string.IsNullOrEmpty(datecreate) ? ConvertUtil.ToDateTime(datecreate) : DateTime.Now;
                    if (!string.IsNullOrEmpty(lstCate))
                    {
                        var lstInt = FDIUtils.StringToListInt(lstCate);
                        model.Categories = _newsDa.GetListCategory(lstInt);
                    }
                    if (!string.IsNullOrEmpty(images))
                    {
                        model.PictureID = int.Parse(images);
                    }

                    if (!string.IsNullOrEmpty(lsttag))
                    {
                        var lstInt = FDIUtils.StringToListInt(lsttag);
                        model.System_Tag = _newsDa.GetListIntTagByArrID(lstInt);
                    }
                    model.IsDeleted = false;
                    _newsDa.Add(model);
                    _newsDa.Save();
                    msg = new JsonMessage
                    {
                        Erros   = false,
                        ID      = model.ID.ToString(),
                        Message = string.Format("Đã thêm mới bài viết: <b>{0}</b>", Server.HtmlEncode(model.Title))
                    };
                }
                catch (Exception ex)
                {
                    LogHelper.Instance.LogError(GetType(), ex);
                }

                break;

            case ActionType.Edit:
                try
                {
                    model = _newsDa.GetById(ArrId.FirstOrDefault());
                    UpdateModel(model);
                    //model.TitleAscii = FomatString.Slug(model.Title);
                    model.DateCreated = !string.IsNullOrEmpty(datecreate) ? ConvertUtil.ToDateTime(datecreate) : DateTime.Now;
                    var membershipUser = Membership.GetUser();
                    if (membershipUser != null)
                    {
                        var providerUserKey = membershipUser.ProviderUserKey;
                        if (providerUserKey != null)
                        {
                            model.Modifier = (Guid)providerUserKey;
                        }
                    }
                    model.Categories.Clear();
                    if (!string.IsNullOrEmpty(lstCate))
                    {
                        var lstInt = FDIUtils.StringToListInt(lstCate);
                        model.Categories = _newsDa.GetListCategory(lstInt);
                    }
                    if (!string.IsNullOrEmpty(images))
                    {
                        model.PictureID = int.Parse(images);
                    }

                    model.System_Tag.Clear();
                    if (!string.IsNullOrEmpty(lsttag))
                    {
                        var lstInt = FDIUtils.StringToListInt(lsttag);
                        model.System_Tag = _newsDa.GetListIntTagByArrID(lstInt);
                    }
                    //model.DateUpdated = DateTime.Now;
                    _newsDa.Save();
                    msg = new JsonMessage
                    {
                        Erros   = false,
                        ID      = model.ID.ToString(),
                        Message = string.Format("Đã cập nhật bài viết: <b>{0}</b>", Server.HtmlEncode(model.Title))
                    };
                }
                catch (Exception ex)
                {
                    LogHelper.Instance.LogError(GetType(), ex);
                }

                break;

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

            case ActionType.Show:
                ltsNewsItems = _newsDa.GetListByArrID(ArrId).Where(o => o.IsShow != true).ToList();     //Chỉ lấy những đối tượng ko được hiển thị
                stbMessage   = new StringBuilder();
                foreach (var item in ltsNewsItems)
                {
                    try
                    {
                        var providerUserKey = Membership.GetUser().ProviderUserKey;
                        if (providerUserKey != null)
                        {
                            item.Modifier = (Guid)providerUserKey;
                        }
                        item.IsShow = true;
                        stbMessage.AppendFormat("Đã hiển thị bài viết <b>{0}</b>.<br />", Server.HtmlEncode(item.Title));
                    }
                    catch (Exception ex)
                    {
                        LogHelper.Instance.LogError(GetType(), ex);
                    }
                }

                _newsDa.Save();
                msg.ID      = string.Join(",", ltsNewsItems.Select(o => o.ID));
                msg.Message = stbMessage.ToString();
                break;

            case ActionType.Hide:
                ltsNewsItems = _newsDa.GetListByArrID(ArrId).Where(o => o.IsShow == true).ToList();     //Chỉ lấy những đối tượng được hiển thị
                stbMessage   = new StringBuilder();
                foreach (var item in ltsNewsItems)
                {
                    try
                    {
                        var providerUserKey = Membership.GetUser().ProviderUserKey;
                        if (providerUserKey != null)
                        {
                            item.Modifier = (Guid)providerUserKey;
                        }
                        item.IsShow = false;
                        stbMessage.AppendFormat("Đã ẩn bài viết <b>{0}</b>.<br />", Server.HtmlEncode(item.Title));
                    }
                    catch (Exception ex)
                    {
                        LogHelper.Instance.LogError(GetType(), ex);
                    }
                }

                _newsDa.Save();
                msg.ID      = string.Join(",", ltsNewsItems.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));
        }
Ejemplo n.º 10
0
        public ActionResult Add(string key, int agencyId, Guid userId)
        {
            var model = new DN_Sale();
            var msg   = new JsonMessage(false, "Thêm mới dữ liệu thành công.");

            try
            {
                var lstproduct = Request["values-arr-product"];
                var dateE      = Request["DateEnd_"];
                var dateS      = Request["DateStart_"];
                var lstCate    = Request["ListCateId"];
                UpdateModel(model);
                model.IsDeleted  = false;
                model.IsShow     = true;
                model.AgencyId   = agencyId;
                model.IsAgency   = false;
                model.UserCreate = userId;
                model.DateEnd    = !string.IsNullOrEmpty(dateE)
                    ? ConvertUtil.ToDateTime(dateE).TotalSeconds()
                    : DateTime.Now.TotalSeconds();
                model.DateStart = !string.IsNullOrEmpty(dateS)
                    ? ConvertUtil.ToDateTime(dateS).TotalSeconds()
                    : DateTime.Now.TotalSeconds();
                if ((!model.QuantityCode.HasValue || model.QuantityCode == 0) && model.IsAll != true && (!model.TotalOrder.HasValue || model.TotalOrder == 0))
                {
                    if (string.IsNullOrEmpty(lstCate))
                    {
                        model.Categories = _da.GetListCateByArrId(lstCate);
                        model.IsAll      = false;
                    }
                    else
                    {
                        if (!string.IsNullOrEmpty(lstproduct))
                        {
                            var lstInt = FDIUtils.StringToListInt(lstproduct);
                            model.Shop_Product_Detail = _da.GetListIntProductByArrId(lstInt);
                            model.IsAll = false;
                        }
                    }
                }
                else
                {
                    model.IsAll = false;
                }
                if (model.IsAll == true)
                {
                    model.QuantityCode = 0;
                }
                if (model.QuantityCode > 0)
                {
                    model.TotalOrder = 0;
                }
                if (model.TotalOrder > 0)
                {
                    model.QuantityCode = 0;
                }
                _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));
        }
Ejemplo n.º 11
0
        public ActionResult Update(string key, Guid userId)
        {
            var msg = new JsonMessage(false, "Cập nhật dữ liệu thành công.");

            try
            {
                if (key != Keyapi)
                {
                    return(Json(0, JsonRequestBehavior.AllowGet));
                }
                var lstproduct = Request["values-arr-product"];
                var dateE      = Request["DateEnd_"];
                var dateS      = Request["DateStart_"];
                var lstCate    = Request["ListCateId"];
                var model      = _da.GetById(ItemId);
                UpdateModel(model);
                model.UserUpdate = userId;
                model.DateEnd    = !string.IsNullOrEmpty(dateE)
                    ? ConvertUtil.ToDateTime(dateE).TotalSeconds()
                    : DateTime.Now.TotalSeconds();
                model.DateStart = !string.IsNullOrEmpty(dateS)
                    ? ConvertUtil.ToDateTime(dateS).TotalSeconds()
                    : DateTime.Now.TotalSeconds();
                model.Shop_Product_Detail.Clear();
                if ((!model.QuantityCode.HasValue || model.QuantityCode == 0) && model.IsAll != true)
                {
                    if (string.IsNullOrEmpty(lstCate))
                    {
                        model.Categories = _da.GetListCateByArrId(lstCate);
                        model.IsAll      = false;
                    }
                    else
                    {
                        if (!string.IsNullOrEmpty(lstproduct))
                        {
                            var lstInt = FDIUtils.StringToListInt(lstproduct);
                            model.Shop_Product_Detail = _da.GetListIntProductByArrId(lstInt);
                            model.IsAll = false;
                        }
                    }
                }
                else
                {
                    model.IsAll = false;
                }
                if (model.IsAll == true)
                {
                    model.QuantityCode = 0;
                    model.TotalOrder   = 0;
                }
                if (model.QuantityCode > 0)
                {
                    model.TotalOrder = 0;
                }
                if (model.TotalOrder > 0)
                {
                    model.QuantityCode = 0;
                }
                _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));
        }
Ejemplo n.º 12
0
        public ActionResult Update(string key)
        {
            try
            {
                if (key != Keyapi)
                {
                    return(Json(0, JsonRequestBehavior.AllowGet));
                }
                var model = _da.GetById(ItemId);
                UpdateModel(model);
                var lstBd = Request["BedDeskID"];
                //var lstP = Request["LstProductID"];
                //model.Shop_Product.Clear();


                model.DN_Bed_Desk.Clear();
                model.Name        = HttpUtility.UrlDecode(model.Name);
                model.DN_Bed_Desk = _da.GetListBeDesk(FDIUtils.StringToListInt(lstBd));
                //model.Shop_Product = _da.GetListProduct(FDIUtils.StringToListInt(lstP));
                var pack = _da.GetListByPacketID(ItemId);
                var dn   = new List <DN_Product_Packet>();
                foreach (var item in pack)
                {
                    var name = Request["Obj_old" + item.ProductId];
                    if (string.IsNullOrEmpty(name))
                    {
                        dn.Add(item);
                    }
                    else
                    {
                        var a = Request["Default_old" + item.ProductId];
                        var c = Request["Obj_old" + item.ProductId];
                        item.ProductId = ConvertUtil.ToInt32(c);
                        item.IsDefault = !string.IsNullOrEmpty(a);
                    }
                }
                foreach (var item in dn)
                {
                    _da.DeleteProductPacket(item);
                }
                var stt = ConvertUtil.ToInt32(Request["do_stt"]);
                for (var i = 1; i <= stt; i++)
                {
                    var a = Request["Default_" + i];
                    var c = Request["Obj_" + i];
                    if (!string.IsNullOrEmpty(c))
                    {
                        var obj = new DN_Product_Packet
                        {
                            ProductId = ConvertUtil.ToInt32(c),
                            IsDefault = !string.IsNullOrEmpty(a),
                            PacketID  = ItemId
                        };
                        _da.AddProduct(obj);
                        //total += obj.Price ?? 0;
                    }
                }
                _da.Save();
                return(Json(1, JsonRequestBehavior.AllowGet));
            }
            catch (Exception)
            {
                return(Json(0, JsonRequestBehavior.AllowGet));
            }
        }
Ejemplo n.º 13
0
        public ActionResult Actions()
        {
            var msg         = new JsonMessage();
            var enterprises = new DN_Enterprises();
            List <DN_Enterprises> ltsEnterprises;
            StringBuilder         stbMessage;
            var dateStart = Request["_DateStart"];
            var dateEnd   = Request["_DateEnd"];
            var pass      = Request["PasswordNew"];
            var groupId   = Request["GroupId"];
            var images    = Request["Value_DefaultImages"];

            switch (DoAction)
            {
            case ActionType.Add:
                try
                {
                    UpdateModel(enterprises);
                    if (!string.IsNullOrEmpty(dateStart) && !string.IsNullOrEmpty(dateEnd))
                    {
                        enterprises.DateStart = dateStart.StringToDecimal();
                        enterprises.DateEnd   = dateEnd.StringToDecimal();
                    }
                    enterprises.DateCreated = DateTime.Now.TotalSeconds();
                    if (!string.IsNullOrEmpty(pass))
                    {
                        var saltKey          = FDIUtils.CreateSaltKey(5);
                        var sha1PasswordHash = FDIUtils.CreatePasswordHash(saltKey, pass);
                        enterprises.PasswordSalt = saltKey;
                        enterprises.Password     = sha1PasswordHash;
                    }
                    enterprises.ST_Group  = _enterprisesDa.GetListGroupByArrID(FDIUtils.StringToListInt(groupId));
                    enterprises.IsDeleted = false;
                    _enterprisesDa.Add(enterprises);
                    _enterprisesDa.Save();
                    msg = new JsonMessage
                    {
                        Erros   = false,
                        ID      = enterprises.ID.ToString(),
                        Message = string.Format("Đã thêm mới hành động: <b>{0}</b>", Server.HtmlEncode(enterprises.Name))
                    };
                }
                catch (Exception ex)
                {
                    LogHelper.Instance.LogError(GetType(), ex);
                }
                break;

            case ActionType.Edit:
                try
                {
                    enterprises = _enterprisesDa.GetById(ArrId.FirstOrDefault());
                    UpdateModel(enterprises);
                    if (!string.IsNullOrEmpty(dateStart) && !string.IsNullOrEmpty(dateEnd))
                    {
                        enterprises.DateStart = dateStart.StringToDecimal();
                        enterprises.DateEnd   = dateEnd.StringToDecimal();
                    }
                    if (!string.IsNullOrEmpty(pass))
                    {
                        var sha1PasswordHash = FDIUtils.CreatePasswordHash(enterprises.PasswordSalt, pass);
                        enterprises.Password = sha1PasswordHash;
                    }
                    enterprises.ST_Group.Clear();
                    enterprises.ST_Group = _enterprisesDa.GetListGroupByArrID(FDIUtils.StringToListInt(groupId));
                    _enterprisesDa.Save();
                    msg = new JsonMessage
                    {
                        Erros   = false,
                        ID      = enterprises.ID.ToString(),
                        Message = string.Format("Đã cập nhật chuyên mục: <b>{0}</b>", Server.HtmlEncode(enterprises.Name))
                    };
                }
                catch (Exception ex)
                {
                    LogHelper.Instance.LogError(GetType(), ex);
                }
                break;

            case ActionType.Delete:
                ltsEnterprises = _enterprisesDa.GetListByArrId(Request["itemID"]);
                stbMessage     = new StringBuilder();
                foreach (var item in ltsEnterprises)
                {
                    item.IsDeleted = true;
                    stbMessage.AppendFormat("Đã xóa chuyên mục <b>{0}</b>.<br />", Server.HtmlEncode(item.Name));
                }
                msg.ID = string.Join(",", ArrId);
                _enterprisesDa.Save();
                msg.Message = stbMessage.ToString();
                break;

            case ActionType.Show:
                ltsEnterprises = _enterprisesDa.GetListByArrId(Request["itemID"]).Where(o => o.IsShow != null && !o.IsShow.Value).ToList();     //Chỉ lấy những đối tượng ko được hiển thị
                stbMessage     = new StringBuilder();
                foreach (var item in ltsEnterprises)
                {
                    item.IsShow = true;
                    stbMessage.AppendFormat("Đã hiển thị chuyên mục <b>{0}</b>.<br />", Server.HtmlEncode(item.Name));
                }
                _enterprisesDa.Save();
                msg.ID      = string.Join(",", ltsEnterprises.Select(o => o.ID));
                msg.Message = stbMessage.ToString();
                break;

            case ActionType.Hide:
                ltsEnterprises = _enterprisesDa.GetListByArrId(Request["itemID"]).Where(o => o.IsShow != null && o.IsShow.Value).ToList();     //Chỉ lấy những đối tượng được hiển thị
                stbMessage     = new StringBuilder();
                foreach (var item in ltsEnterprises)
                {
                    item.IsShow = false;
                    stbMessage.AppendFormat("Đã ẩn chuyên mục <b>{0}</b>.<br />", Server.HtmlEncode(item.Name));
                }
                _enterprisesDa.Save();
                msg.ID      = string.Join(",", ltsEnterprises.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));
        }
Ejemplo n.º 14
0
        public void InsertRewardOrderPacket(CustomerAppIG4Item shop, ConfigExchange config, decimal?totalprice, int OrderId, List <BonusTypeItem> bonusItems, int type = 0, int idkho = 0, decimal discountKH = 60)
        {
            var now      = DateTime.Now.TotalSeconds();
            var today    = DateTime.Today.TotalSeconds();
            var totalD   = totalprice * config.DiscountOrderPacket / 100;
            var ltsArrId = FDIUtils.StringToListInt(shop.ListAgencyId);

            ltsArrId = ltsArrId.Take(bonusItems.Count).ToList();
            var     listcustomer = _agencyDa.GetListAgencyListID(ltsArrId);
            decimal per          = 0;
            var     i            = 1;

            foreach (var item in listcustomer)
            {
                if (i <= bonusItems.Count)
                {
                    //if (item.LevelAdd >= i)
                    //{
                    var bonusItem = bonusItems.FirstOrDefault(m => m.ID == i);
                    if (bonusItem != null)
                    {
                        var reward = new RewardHistory
                        {
                            Price = totalD * (bonusItem.Percent / 100),
                            //CustomerID = item.ID,
                            Date          = now,
                            DateCreate    = today,
                            OrderPacketID = OrderId,
                            Type          = (int)Reward.Packet,
                            BonusTypeId   = i,
                            Percent       = bonusItem.Percent,
                            IsDeleted     = false,
                            IsActive      = true,
                            AgencyId      = item.ID,
                            TotalCp       = totalD,
                        };
                        _rewardHistoryDa.Add(reward);
                        //var cus = _customerDa.GetItemByID(item.ID);
                        //var shopsucess = _orderDa.GetNotifyById(6);
                        //var tokenshop = cus.tokenDevice;
                        //Pushnotifycation(shopsucess.Title, shopsucess.Content.Replace("{price}", reward.Price.Money().Replace("{hoahong}", bonusItem.Name).Replace("{customer}", item.Fullname)), tokenshop);
                        per += bonusItem.Percent ?? 0;
                    }
                }
                i++;
            }
            var reward0 = new RewardHistory
            {
                Price = totalD * ((100 - per) / 100),
                //CustomerID = item.ID,
                Date          = now,
                DateCreate    = today,
                OrderPacketID = OrderId,
                Type          = (int)Reward.Packet,
                //BonusTypeId = i,
                Percent   = 100 - per,
                IsDeleted = false,
                IsActive  = true,
                AgencyId  = shop.AgencyID,
                TotalCp   = totalD,
            };

            _rewardHistoryDa.Add(reward0);
            var reward1 = new RewardHistory
            {
                Price = totalprice * (100 - config.DiscountOrderPacket) / 100,
                //CustomerID = item.ID,
                Date          = now,
                DateCreate    = today,
                OrderPacketID = OrderId,
                Type          = (int)Reward.Packet,
                //BonusTypeId = i,
                Percent   = 100 - config.DiscountOrderPacket,
                IsDeleted = false,
                IsActive  = true,
                AgencyId  = 1006,
                TotalCp   = totalprice * (100 - config.DiscountOrderPacket) / 100,
            };

            _rewardHistoryDa.Add(reward1);
            _rewardHistoryDa.Save();
        }
Ejemplo n.º 15
0
        public void InsertRewardOrderCustomer(CustomerAppIG4Item customer, ConfigExchange config, decimal?totalprice, int OrderId, List <BonusTypeItem> bonusItems, int type = 0, int idkho = 0, decimal discountKH = 60)
        {
            var now = DateTime.Now.TotalSeconds();
            //hoa hong cho shop ky gui
            //if (type == 2)
            //{
            //    // chinh sach them cho don hang ban tu kho.
            //    var customer = _customerDa.GetItemByID(idkho);
            //    var bonusItem = bonusItems.FirstOrDefault(m => m.ID == 1);
            //    if (bonusItem != null)
            //    {
            //        var reward = new RewardHistory
            //        {
            //            Price = (totalprice ?? 0) * (bonusItem.Percent / 100),
            //            CustomerID = customer.ID,
            //            Date = now,
            //            OrderID = OrderId,
            //            Type = (int)Reward.Kho,
            //            BonusTypeId = 1,
            //            Percent = bonusItem.Percent,
            //            IsDeleted = false,
            //            IsActive = true,
            //            AgencyId = 1006,
            //            TotalCp = totalprice,
            //        };
            //        _rewardHistoryDa.Add(reward);
            //        var shopsucess = _orderDa.GetNotifyById(9);
            //        var tokenshop = customer.tokenDevice;
            //        Pushnotifycation(shopsucess.Title, shopsucess.Content.Replace("{price}", reward.Price.Money()), tokenshop);
            //    }
            //    var listcustomer = _customerDa.GetItemByID(parentId);
            //    var bonusItemparent = bonusItems.FirstOrDefault(m => m.ID == 2);
            //    if (bonusItemparent != null)
            //    {
            //        var reward = new RewardHistory
            //        {
            //            Price = (totalprice ?? 0) * (bonusItemparent.Percent / 100),
            //            CustomerID = listcustomer.ID,
            //            Date = now,
            //            OrderID = OrderId,
            //            Type = (int)Reward.Kho,
            //            BonusTypeId = 2,
            //            Percent = bonusItemparent.Percent,
            //            IsDeleted = false,
            //            IsActive = true,
            //            AgencyId = 1006,
            //            TotalCp = totalprice,
            //        };
            //        _rewardHistoryDa.Add(reward);
            //        var shopsucess = _orderDa.GetNotifyById(9);
            //        var tokenshop = listcustomer.tokenDevice;
            //        Pushnotifycation(shopsucess.Title, shopsucess.Content.Replace("{price}", reward.Price.Money()), tokenshop);
            //    }
            //    var bonusItemroot = bonusItems.FirstOrDefault(m => m.ID == 3);
            //    if (bonusItemroot != null)
            //    {
            //        var reward = new RewardHistory
            //        {
            //            Price = (totalprice ?? 0) * (bonusItemroot.Percent / 100),
            //            CustomerID = 1,
            //            Date = now,
            //            OrderID = OrderId,
            //            Type = (int)Reward.Kho,
            //            BonusTypeId = 3,
            //            Percent = bonusItemroot.Percent,
            //            IsDeleted = false,
            //            IsActive = true,
            //            AgencyId = 1006,
            //            TotalCp = totalprice,
            //        };
            //        _rewardHistoryDa.Add(reward);
            //        //var shopsucess = _orderDa.GetNotifyById(9);
            //        //var tokenshop = root.tokenDevice;
            //        //Pushnotifycation(shopsucess.Title, shopsucess.Content.Replace("{price}", reward.Price.Money()), tokenshop);
            //    }
            //    _rewardHistoryDa.Save();
            //}
            //else
            //{
            var totalD   = totalprice * config.DiscountCTV / 100;
            var ltsArrId = FDIUtils.StringToListInt(customer.ListAgencyId);

            ltsArrId = ltsArrId.Take(bonusItems.Count).ToList();
            var     listcustomer = _agencyDa.GetListAgencyListID(ltsArrId);
            decimal per          = 0;
            var     i            = 1;

            foreach (var item in listcustomer)
            {
                if (i <= bonusItems.Count)
                {
                    //if (item.LevelAdd >= i)
                    //{
                    var bonusItem = bonusItems.FirstOrDefault(m => m.ID == i);
                    if (bonusItem != null)
                    {
                        var reward = new RewardHistory
                        {
                            Price = totalD * (bonusItem.Percent / 100),
                            //CustomerID = item.ID,
                            Date        = now,
                            OrderID     = OrderId,
                            Type        = (int)Reward.Cus,
                            BonusTypeId = i,
                            Percent     = bonusItem.Percent,
                            IsDeleted   = false,
                            IsActive    = true,
                            AgencyId    = item.ID,
                            TotalCp     = totalD,
                        };
                        _rewardHistoryDa.Add(reward);
                        //var cus = _customerDa.GetItemByID(item.ID);
                        //var shopsucess = _orderDa.GetNotifyById(6);
                        //var tokenshop = cus.tokenDevice;
                        //Pushnotifycation(shopsucess.Title, shopsucess.Content.Replace("{price}", reward.Price.Money().Replace("{hoahong}", bonusItem.Name).Replace("{customer}", item.Fullname)), tokenshop);
                        per += bonusItem.Percent ?? 0;
                    }
                    //}
                }
                i++;
            }
            var reward0 = new RewardHistory
            {
                Price = totalD * ((100 - per) / 100),
                //CustomerID = item.ID,
                Date        = now,
                OrderID     = OrderId,
                Type        = (int)Reward.Cus,
                BonusTypeId = i,
                Percent     = 100 - per,
                IsDeleted   = false,
                IsActive    = true,
                AgencyId    = customer.AgencyID,
                TotalCp     = totalD,
            };

            _rewardHistoryDa.Add(reward0);
            //}

            // % chiết khấu cho công ty
            var reward1 = new RewardHistory
            {
                Price      = (totalprice ?? 0) * config.DiscountOrder / 100,
                CustomerID = 1,
                Date       = now,
                OrderID    = OrderId,
                Type       = (int)Reward.Cus,
                //BonusTypeId = i,
                Percent   = config.DiscountOrder,
                IsDeleted = false,
                IsActive  = true,
                AgencyId  = 1006,
                TotalCp   = totalprice,
            };

            _rewardHistoryDa.Add(reward1);
            // % chiết khấu cho mã QR truy xuất nguồn gốc
            var reward2 = new RewardHistory
            {
                Price      = (totalprice ?? 0) * config.DiscountQR / 100,
                CustomerID = 1,
                Date       = now,
                OrderID    = OrderId,
                Type       = (int)Reward.QR,
                //BonusTypeId = i,
                Percent   = config.DiscountQR,
                IsDeleted = false,
                IsActive  = true,
                AgencyId  = 1006,
                TotalCp   = totalprice,
            };

            _rewardHistoryDa.Add(reward2);
            // % chiết khấu cho quỹ khuyến mãi KH
            var reward3 = new RewardHistory
            {
                Price      = (totalprice ?? 0) * config.DiscountSale / 100,
                CustomerID = 1,
                Date       = now,
                OrderID    = OrderId,
                Type       = (int)Reward.Sale,
                //BonusTypeId = i,
                Percent   = config.DiscountSale,
                IsDeleted = false,
                IsActive  = true,
                AgencyId  = 1006,
                TotalCp   = totalprice,
            };

            _rewardHistoryDa.Add(reward3);

            // % phát triển cty
            var reward4 = new RewardHistory
            {
                Price      = (totalprice ?? 0) * (100 - discountKH - config.DiscountQR - config.DiscountOrder - config.DiscountSale - config.DiscountCTV - config.DiscountOrderAgency) / 100,
                CustomerID = 1,
                Date       = now,
                OrderID    = OrderId,
                Type       = (int)Reward.Depvelop,
                //BonusTypeId = i,
                Percent   = (100 - discountKH - config.DiscountQR - config.DiscountOrder - config.DiscountSale - config.DiscountCTV - config.DiscountOrderAgency),
                IsDeleted = false,
                IsActive  = true,
                AgencyId  = 1006,
                TotalCp   = totalprice,
            };

            _rewardHistoryDa.Add(reward4);
            _rewardHistoryDa.Save();
        }