Example #1
0
        public JsonResult OnCreate(string pTieuDe, int?pGroupId, int?pUuTien, string pKichCo, string pImageUrl)
        {
            ImageType mImageType;

            string[] mLevelArray;
            var      mLevel = 0;

            if (pGroupId == 0)
            {
                //Tinh gia tri Level moi cho Group nay
                //1- Lay tat ca cac Group me
                //2- Convert gia tri Level de lay gia tri lon nhat
                //3- Tao gia tri moi lon hon gia tri lon nhat
                mLevelArray = (from p in MpStartEntities.ImageType
                               where p.Parent == 0
                               select p.Level).ToArray();
                mLevel     = mLevelArray.Select(p => Convert.ToInt32(p)).ToArray().Max();
                mLevel     = (mLevel + 1);
                mImageType = new ImageType()
                {
                    Date = DateTime.Now, Level = mLevel.ToString(), Number = pUuTien, Name = pTieuDe, Parent = pGroupId, Size = pKichCo, Image = pImageUrl
                };
                MpStartEntities.AddToImageType(mImageType);
                MpStartEntities.SaveChanges();
            }
            else
            {
                //lay level cua nhom me
                var mImageTypeParent = ImagesService.LayTheLoaiAnhTheoId((int)pGroupId);
                if (mImageTypeParent != null)
                {
                    mLevelArray = (from p in MpStartEntities.NewsGroups
                                   where (p.Level.Substring(0, mImageTypeParent.Level.Length).Equals(mImageTypeParent.Level)) && (p.Level.Length == (mImageTypeParent.Level.Length + 5))
                                   select p.Level).ToArray();
                    if (mLevelArray.Any())
                    {
                        mLevel = mLevelArray.Select(p => Convert.ToInt32(p)).ToArray().Max();
                        mLevel = (mLevel + 1);
                    }
                    else
                    {
                        mLevel = Convert.ToInt32(mImageTypeParent.Level.ToString().Trim() + "10001");
                    }
                    mImageType = new ImageType()
                    {
                        Date = DateTime.Now, Level = mLevel.ToString(), Number = pUuTien, Name = pTieuDe, Parent = pGroupId, Size = pKichCo, Image = pImageUrl
                    };
                    MpStartEntities.AddToImageType(mImageType);
                    MpStartEntities.SaveChanges();
                }
                else
                {
                    return(Json(new { code = 0, message = "Không tìm thấy nhóm ảnh." }));
                }
            }
            return(Json(new { code = 1, message = "Lưu loại ảnh thành công." }));
        }
Example #2
0
        public JsonResult OnCreate(string pTieuDe, int?pUuTien, int?pGroupId, string pNick, string pMobile, string pEmail)
        {
            var mSupport = new Support()
            {
                Date = DateTime.Now, Name = pTieuDe, TypeID = pGroupId, Phone = pMobile, Nick = pNick, Email = pEmail
            };

            MpStartEntities.AddToSupport(mSupport);
            MpStartEntities.SaveChanges();
            return(Json(new { code = 1, message = "Lưu loại hỗ trợ thành công." }));
        }
Example #3
0
        public JsonResult OnCreate(string pTieuDe, int?pUuTien)
        {
            var mSupportType = new SupportType()
            {
                Date = DateTime.Now, Number = pUuTien, Name = pTieuDe
            };

            MpStartEntities.AddToSupportType(mSupportType);
            MpStartEntities.SaveChanges();
            return(Json(new { code = 1, message = "Lưu loại hỗ trợ thành công." }));
        }
Example #4
0
        public JsonResult OnDelete(int pId = 0)
        {
            var mSupportType = SupportService.LaySupportTypeTheoId(pId);

            if (mSupportType != null)
            {
                MpStartEntities.DeleteObject(mSupportType);
                MpStartEntities.SaveChanges();
                return(Json(new { code = 1, message = "Xóa thành công!" }));
            }
            return(Json(new { code = 0, message = "Không tìm thấy kiểu cần xóa." }));
        }
Example #5
0
        public JsonResult OnChangeStatus(int pId = 0)
        {
            var mAccount = AccountService.LayTinTheoId(pId);

            if (mAccount != null)
            {
                mAccount.Status = !mAccount.Status;
                MpStartEntities.SaveChanges();
                return(Json(new { code = 1, message = (mAccount.Status == true ? "Kích hoạt thành công!" : "Khóa tài khoản thành công!") }));
            }
            return(Json(new { code = 0, message = "Không tìm thấy tài khoản cần xóa." }));
        }
Example #6
0
        public JsonResult OnDelete(int pId = 0)
        {
            var mAccount = AccountService.LayTinTheoId(pId);

            if (mAccount != null)
            {
                MpStartEntities.DeleteObject(mAccount);
                MpStartEntities.SaveChanges();
                return(Json(new { code = 1, message = "Xóa thành công!" }));
            }
            return(Json(new { code = 0, message = "Không tìm thấy tài khoản cần xóa." }));
        }
Example #7
0
        public JsonResult OnDelete(int pId = 0)
        {
            var mImage = ImagesService.LayAnhTheoId(pId);

            if (mImage != null)
            {
                MpStartEntities.DeleteObject(mImage);
                MpStartEntities.SaveChanges();
                return(Json(new { code = 1, message = "Xóa thành công!" }));
            }
            return(Json(new { code = 0, message = "Không tìm thấy tin cần xóa." }));
        }
Example #8
0
        public JsonResult OnDelete(int pId = 0)
        {
            var mProductOrder = ProductsService.LayProductOrderTheoId(pId);

            if (mProductOrder != null)
            {
                MpStartEntities.DeleteObject(mProductOrder);
                MpStartEntities.SaveChanges();
                return(Json(new { code = 1, message = "Xóa thành công!" }));
            }
            return(Json(new { code = 0, message = "Không tìm thấy hóa đơn cần xóa." }));
        }
Example #9
0
        public JsonResult OrderXacNhan(int pId = 0)
        {
            var mProductOrder = ProductsService.LayProductOrderTheoId(pId);

            if (mProductOrder != null)
            {
                mProductOrder.Status = 1;
                MpStartEntities.SaveChanges();
                return(Json(new { code = 1, message = "Xác nhận thành công!" }));
            }
            return(Json(new { code = 0, message = "Không tìm thấy hóa đơn cần Xác nhận." }));
        }
Example #10
0
        public JsonResult OnEdit(int pId, string pTieuDe, int?pUuTien)
        {
            var mSupportType = SupportService.LaySupportTypeTheoId(pId);

            if (mSupportType != null)
            {
                mSupportType.Name   = pTieuDe;
                mSupportType.Date   = DateTime.Now;
                mSupportType.Number = pUuTien;
                MpStartEntities.SaveChanges();
                return(Json(new { code = 1, message = "Sủa thể loại hỗ trợ thành công." }));
            }
            return(Json(new { code = 0, message = "Không tìm thấy hỗ trợ để sửa." }));
        }
Example #11
0
        public JsonResult OnCreate(string pTitle, int?pGroupId, string pLink, string pSummary, string pImageUrl)
        {
            var mImage = new Image()
            {
                Date      = DateTime.Now,
                Link      = pLink,
                LinkImage = pImageUrl,
                Name      = pTitle,
                Summary   = pSummary,
                TypeID    = pGroupId
            };

            MpStartEntities.AddToImage(mImage);
            MpStartEntities.SaveChanges();
            return(Json(new { code = 1, message = "Lưu  ảnh thành công." }));
        }
Example #12
0
        public JsonResult OnEdit(int pId, string pTieuDe, int?pUuTien, int?pGroupId, string pNick, string pMobile, string pEmail)
        {
            var mSupport = SupportService.LayTheoId(pId);

            if (mSupport != null)
            {
                mSupport.Name   = pTieuDe;
                mSupport.Date   = DateTime.Now;
                mSupport.TypeID = pGroupId;
                mSupport.Nick   = pNick;
                mSupport.Phone  = pMobile;
                mSupport.Email  = pEmail;
                MpStartEntities.SaveChanges();
                return(Json(new { code = 1, message = "Sủa thể hỗ trợ thành công." }));
            }
            return(Json(new { code = 0, message = "Không tìm thấy hỗ trợ để sửa." }));
        }
Example #13
0
        public JsonResult OnEdit(int pId, string pTitle, int?pGroupId, string pLink, string pSummary, string pImageUrl)
        {
            var mImage = ImagesService.LayAnhTheoId(pId);

            if (mImage != null)
            {
                mImage.Name      = pTitle;
                mImage.TypeID    = pGroupId;
                mImage.Link      = pLink;
                mImage.LinkImage = pImageUrl;
                mImage.Summary   = pSummary;
                mImage.Date      = DateTime.Now;
                MpStartEntities.SaveChanges();
                return(Json(new { code = 1, message = "Sủa ảnh thành công." }));
            }
            return(Json(new { code = 0, message = "Không tìm thấy ảnh để sửa." }));
        }
Example #14
0
        public JsonResult OnCreate(string pTitle, int?pGroupId, string pLink, string pKichHoat, int?pValue, string pSummary, string pImageUrl)
        {
            var mFile = new File()
            {
                Date     = DateTime.Now,
                LinkFile = pImageUrl,
                Status   = ConverterUlti.ConvertStringToLogic2(pKichHoat),
                FileName = pTitle,
                Summary  = pSummary,
                TypeID   = pGroupId,
                Value    = pValue
            };

            MpStartEntities.AddToFile(mFile);
            MpStartEntities.SaveChanges();
            return(Json(new { code = 1, message = "Lưu  File thành công." }));
        }
Example #15
0
        public JsonResult OnEdit(int pId, string pTieuDe, int?pGroupId, int?pUuTien, string pKichCo, string pImageUrl)
        {
            var mImageType = ImagesService.LayTheLoaiAnhTheoId(pId);

            if (mImageType != null)
            {
                mImageType.Name   = pTieuDe;
                mImageType.Date   = DateTime.Now;
                mImageType.Number = pUuTien;
                mImageType.Parent = pGroupId;
                mImageType.Size   = pKichCo;
                mImageType.Image  = pImageUrl;
                MpStartEntities.SaveChanges();
                return(Json(new { code = 1, message = "Sủa thể loại ảnh thành công." }));
            }
            return(Json(new { code = 0, message = "Không tìm thấy loại ảnh để sửa." }));
        }
Example #16
0
        public JsonResult OnEdit(int pId, string pTitle, int?pGroupId, int?pValue, string pLink, string pKichHoat, string pSummary, string pImageUrl)
        {
            var mFile = FileService.LayFileTheoId(pId);

            if (mFile != null)
            {
                mFile.FileName = pTitle;
                mFile.TypeID   = pGroupId;
                mFile.LinkFile = pImageUrl;
                mFile.Summary  = pSummary;
                mFile.Date     = DateTime.Now;
                mFile.Value    = pValue;
                mFile.Status   = ConverterUlti.ConvertStringToLogic2(pKichHoat);
                MpStartEntities.SaveChanges();
                return(Json(new { code = 1, message = "Sủa File thành công." }));
            }
            return(Json(new { code = 0, message = "Không tìm thấy File để sửa." }));
        }
Example #17
0
        public JsonResult OnEdit(int pId, string pTieuDe, int?pGroupId, int?pUuTien, string pKichCo, string pImageUrl)
        {
            var mFileType = FileService.LayTheLoaiFileTheoId(pId);

            if (mFileType != null)
            {
                mFileType.Name     = pTieuDe;
                mFileType.Date     = DateTime.Now;
                mFileType.Number   = pUuTien;
                mFileType.ParentID = pGroupId;
                MpStartEntities.SaveChanges();
                return(Json(new { code = 1, message = "Sủa thể loại File thành công." }));
            }
            else
            {
                return(Json(new { code = 0, message = "Không tìm thấy loại File để sửa." }));
            }
        }
Example #18
0
        public JsonResult OnDelete(int pId = 0)
        {
            var mMarket = MarketService.LayTheoId(pId);

            if (mMarket != null)
            {
                //lay danh sach cac san pham cua sieu thi
                var mList = ProductsService.getByPageSizeMarketId(1, 1000, mMarket.ID);
                //xoa cac san pham nay
                foreach (Product it in mList)
                {
                    MpStartEntities.DeleteObject(it);
                }
                MpStartEntities.DeleteObject(mMarket);
                MpStartEntities.SaveChanges();
                return(Json(new { code = 1, message = "Xóa thành công!" }));
            }
            return(Json(new { code = 0, message = "Không tìm thấy tài khoản cần xóa." }));
        }
Example #19
0
        public JsonResult OnCreate(string pUserName, string pAvata, int pMarketType, string pEmail, string pFullName, string pMobile, string pSumary, bool pActive = true)
        {
            var mMarket = new Market()
            {
                Date     = DateTime.Now,
                BirthDay = DateTime.Now,
                UserName = Ultility.LocDau2(pUserName.Trim()),
                Avata    = pAvata,
                Email    = pEmail,
                FullName = pFullName,
                Gender   = true,
                Phone    = pMobile,
                Role     = pMarketType,
                Status   = pActive,
                Sumary   = pSumary
            };

            MpStartEntities.AddToMarket(mMarket);
            MpStartEntities.SaveChanges();
            //lay danh sách nhom san pham
            var mList = ProductsService.getProductTypeParent();

            foreach (ProductType it in mList)
            {
                MarketProductType mMarketProductType = new MarketProductType()
                {
                    Date        = DateTime.Now,
                    Name        = it.Name,
                    Detail      = it.Name,
                    Parent      = it.ID,
                    Status      = true,
                    Visible     = true,
                    Number      = 1,
                    MarketId    = mMarket.ID,
                    MarketName  = mMarket.UserName,
                    ImageBanner = it.ImageBanner
                };
                MpStartEntities.AddToMarketProductType(mMarketProductType);
            }
            MpStartEntities.SaveChanges();
            return(Json(new { code = 1, message = "Lưu cửa hàng thành công." }));
        }
Example #20
0
        public JsonResult OnEdit(int pId, string pUserName, string pAvata, string pEmail, int pMarketType, string pFullName, string pMobile, string pSumary, bool pActive = true)
        {
            var mMarket = MarketService.LayTheoId(pId);

            if (mMarket != null)
            {
                mMarket.UserName = pUserName;
                mMarket.Date     = DateTime.Now;
                mMarket.Avata    = pAvata;
                mMarket.Email    = pEmail;
                mMarket.FullName = pFullName;
                mMarket.Phone    = pMobile;
                mMarket.Sumary   = pSumary;
                mMarket.Status   = pActive;
                mMarket.Role     = pMarketType;
                MpStartEntities.SaveChanges();
                return(Json(new { code = 1, message = "Sủa cửa hàng thành công." }));
            }
            return(Json(new { code = 0, message = "Không tìm thấy cửa hàng để sửa." }));
        }