예제 #1
0
        public ActionResult ProfileUser()
        {
            V308CMSEntities   mEntities         = new V308CMSEntities();
            MarketRepository  marketRepository  = new MarketRepository(mEntities);
            AccountRepository accountRepository = new AccountRepository(mEntities);
            HeaderPage        mHeaderPage       = new HeaderPage();
            List <Market>     mList;
            Account           mAccount;

            try
            {
                //Check xem dang nhap chưa thi hien thi menu khac
                // && Session["ShopCart"] != null
                if (HttpContext.User.Identity.IsAuthenticated == true && Session["UserId"] != null)
                {
                    //lay thong tin chi tiet user
                    mAccount = accountRepository.LayTinTheoId(Int32.Parse(Session["UserId"].ToString()));
                    mHeaderPage.IsAuthenticated = true;
                    mHeaderPage.Account         = mAccount;
                }
                return(View(mHeaderPage));
            }
            catch (Exception ex)
            {
                return(Content("<dx></dx>"));
            }
            finally
            {
                mEntities.Dispose();
                marketRepository.Dispose();
            }
        }
예제 #2
0
        public ActionResult MarketList(int ptype = 0)
        {
            V308CMSEntities  mEntities        = new V308CMSEntities();
            MarketRepository marketRepository = new MarketRepository(mEntities);
            List <Market>    mList            = new List <Market>();

            try
            {
                //lay danh sach nhom tin
                mList          = marketRepository.getMarketByType(100, ptype);
                ViewBag.MkType = ptype;
                //lay danh sach cac tin theo nhom
                return(View(mList));
            }
            catch (Exception ex)
            {
                Console.WriteLine("error :", ex);
                return(Content("<dx></dx>"));
            }
            finally
            {
                mEntities.Dispose();
                marketRepository.Dispose();
            }
        }
예제 #3
0
        public ActionResult Header()
        {
            V308CMSEntities   mEntities         = new V308CMSEntities();
            MarketRepository  marketRepository  = new MarketRepository(mEntities);
            AccountRepository accountRepository = new AccountRepository(mEntities);
            HeaderPage        mHeaderPage       = new HeaderPage();
            List <Market>     mList;
            Account           mAccount;

            try
            {
                //Check xem dang nhap chưa thi hien thi menu khac
                // && Session["ShopCart"] != null
                if (HttpContext.User.Identity.IsAuthenticated == true && Session["UserId"] != null)
                {
                    //lay thong tin chi tiet user
                    mAccount = accountRepository.LayTinTheoId(Int32.Parse(Session["UserId"].ToString()));
                    mHeaderPage.IsAuthenticated = true;
                    mHeaderPage.Account         = mAccount;
                }
                if (Session["ShopCart"] != null)
                {
                    mHeaderPage.ShopCart = (ShopCart)Session["ShopCart"];
                }
                else
                {
                    mHeaderPage.ShopCart = null;
                }
                //lay danh sach nhom tin
                mList = marketRepository.getAll(8);
                mHeaderPage.Market = mList;
                //lay danh sach cac tin theo nhom
                //
                //
                //
                if (Request.Cookies["location"] != null && Request.Cookies["locationname"] != null)
                {
                    ViewBag.location     = Int32.Parse(Request.Cookies["location"].Value);
                    ViewBag.locationname = Ultility.convertValueToDistrict(Int32.Parse(Request.Cookies["location"].Value));
                }
                else
                {
                    ViewBag.location     = 0;
                    ViewBag.locationname = "Hà Nội";
                }
                //
                return(View("Header", mHeaderPage));
            }
            catch (Exception ex)
            {
                Console.Write(ex);
                return(Content("<dx></dx>"));
            }
            finally
            {
                mEntities.Dispose();
                marketRepository.Dispose();
            }
        }
예제 #4
0
 private void DisposeRepos()
 {
     mEntities.Dispose();
     if (ProductRepos != null)
     {
         ProductRepos.Dispose();
     }
     if (NewsRepos != null)
     {
         NewsRepos.Dispose();
     }
     if (MarketRepos != null)
     {
         MarketRepos.Dispose();
     }
 }
예제 #5
0
        public ActionResult MarketList()
        {
            V308CMSEntities  mEntities        = new V308CMSEntities();
            MarketRepository marketRepository = new MarketRepository(mEntities);
            List <Market>    mList            = new List <Market>();

            try
            {
                //lay danh sach nhom tin
                mList = marketRepository.getAll(10);
                //lay danh sach cac tin theo nhom
                return(View(mList));
            }
            catch (Exception ex)
            {
                return(Content("<dx></dx>"));
            }
            finally
            {
                mEntities.Dispose();
                marketRepository.Dispose();
            }
        }
예제 #6
0
        public JsonResult CheckMarketRegister(string pUserName, string pPassWord, string pPassWord2, string pEmail, string pMobile, int pMarketType, string pSummary, string pImage, string pSumary, string InvisibleCaptchaValue, string Captcha = "", bool rbtAgree = false, string pFullName = "")
        {
            V308CMSEntities    mEntities         = new V308CMSEntities();
            MarketRepository   marketRepository  = new MarketRepository(mEntities);
            ProductRepository  productRepository = new ProductRepository(mEntities);
            AccountRepository  accountRepository = new AccountRepository(mEntities);
            List <ProductType> mList;
            Market             mMarket;
            Admin mAdmin;

            try
            {
                if (pPassWord.Trim().Equals(pPassWord2.Trim()))
                {
                    if (pEmail.Length > 5 && pPassWord.Length > 5)
                    {
                        mAdmin = accountRepository.LayAdminTheoUserName(pEmail);
                        if (!(mAdmin != null))
                        {
                            mAdmin = new Admin()
                            {
                                Date     = DateTime.Now,
                                Role     = 1,
                                FullName = pFullName,
                                Email    = pEmail,
                                UserName = pEmail,
                                Password = EncryptionMD5.ToMd5(pPassWord.Trim()),
                                //PSanPham = (true),
                                //PFileUpload = (true),
                                //PHeThong = (true),
                                //PHinhAnh = (true),
                                //PKhachHang = (true),
                                //PTaiKhoan = (true),
                                //PThungRac = (true),
                                //PTinTuc = (true),
                                Status = false
                            };
                            mEntities.AddToAdmin(mAdmin);
                            mEntities.SaveChanges();
                            //return Json(new { code = 1, message = "Lưu  tài khoản thành công." });
                        }
                        else
                        {
                            return(Json(new { code = 0, message = "Tài khoản đã tồn tại. Vui lòng tại tài khoản mới." }));
                        }
                    }
                    else
                    {
                        return(Json(new { code = 0, message = "Mật khẩu và tài khoản và có độ dài tối thiểu 6 kí tự." }));
                    }
                }
                else
                {
                    return(Json(new { code = 0, message = "Mật khẩu xác nhận không trùng khớp." }));
                }
                ////////////////////////////////////////////////////////////////////////////////////
                /////////////////////////TẠO GIAN HÀNG
                ///////////////////////////////////////////////////////////////////////////////////
                ///////////////////////////////////////////////////////////////////////////////////
                pImage  = "http://cleanfoodvn.vn/Content/Images/logo.png";
                mMarket = new Market()
                {
                    Date = DateTime.Now, UserId = mAdmin.ID, BirthDay = DateTime.Now, UserName = Ultility.LocDau2(pUserName.Trim()), Avata = pImage, Email = pEmail, FullName = pFullName, Gender = true, Phone = pMobile, Role = pMarketType, Status = false, Sumary = pSumary
                };
                mEntities.AddToMarket(mMarket);
                mEntities.SaveChanges();
                //lay danh sách nhom san pham
                mList = productRepository.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
                    };
                    mEntities.AddToMarketProductType(mMarketProductType);
                }
                mEntities.SaveChanges();
                return(Json(new { code = 1, message = "Lưu cửa hàng thành công." }));
            }
            catch (Exception ex)
            {
                return(Json(new { code = 0, message = "Có lỗi xảy ra. Vui lòng thử lại." }));
            }
            finally
            {
                mEntities.Dispose();
                marketRepository.Dispose();
            }
        }