Exemplo n.º 1
0
        public ActionResult DeleteDianPu(int id)
        {
            ListShops shop = ListShopsServices.LoadEntities(u => u.Id == id).FirstOrDefault();

            shop.Status   = 0;
            shop.IsShenHe = 0;
            ListShopsServices.Update(shop);

            #region 给用户发送消息
            MyNews news = new MyNews();
            news.SubTime    = DateTime.Now;
            news.Title      = "您的店铺由于违反相关法律法规已被管理员关闭,如果您想再次开店请先进行开店申请操作";
            news.UserInfoId = shop.UserInfoId;
            news.IsSee      = 0;
            MyNewsServices.Add(news);
            #endregion

            #region  除用户所有商品信息
            var listGoods = GoodsServices.LoadEntities(u => u.UserInfoId == shop.UserInfoId).ToList();
            foreach (var item in listGoods)
            {
                item.DelGlag = 0;
                GoodsServices.Update(item);
            }
            #endregion


            return(Redirect("/Admin/ListDianpu"));
        }
        public ActionResult Shop(int?pageIndex)
        {
            var goodIds = ShopingServices.LoadEntities(s => s.UserInfoId == CurrentLoginUser.Id && s.DelFlag == normal);

            if (pageIndex == null || pageIndex <= 0)
            {
                pageIndex = 1;
            }

            List <Shops> list = new List <Shops>();

            int total = 0;

            if (goodIds != null)
            {
                foreach (var item in goodIds)
                {
                    Shops shop   = new Shops();
                    int   goodid = item.GoodsId;
                    Goods good   = GoodsServices.LoadPageEntities((int)pageIndex, 5, out total, u => u.Id == goodid
                                                                  , u => u.Id, true).FirstOrDefault();

                    shop.ShopId = item.Id;
                    shop.Goods  = good;
                    list.Add(shop);
                }
            }

            ViewData["allGoods"]  = list;
            ViewData["pageIndex"] = pageIndex;
            ViewData["Count"]     = total;
            return(View());
        }
        public ActionResult EditGoods(int?id)
        {
            if (id == null)
            {
                return(Content("参数错误"));
            }
            UserInfo user = CurrentLoginUser;

            if (user == null)
            {
                return(Redirect("/Account/Login"));
            }

            var good = GoodsServices.LoadEntities(u => u.DelGlag == normal && u.UserInfoId == user.Id && u.Id == id).FirstOrDefault();


            var sale = SaleInfoServices.LoadEntities(u => u.GoodsId == id).FirstOrDefault();

            if (good == null || sale == null)
            {
                return(Content("参数错误"));
            }


            ViewBag.Sale = sale;

            return(View(good));
        }
Exemplo n.º 4
0
        public ActionResult AddShouCang(int userId, int goodId)
        {
            var good = GoodsServices.LoadEntities(u => u.Id == goodId).FirstOrDefault();

            if (good == null)
            {
                return(Content("数据有误"));
            }

            Shoping shop = new Shoping();

            shop.GoodsId    = good.Id;
            shop.UserInfoId = userId;
            shop.DelFlag    = normal;
            shop.SubTime    = DateTime.Now;

            try
            {
                ShopingServices.Add(shop);
                return(Content("加入收藏成功"));
            }
            catch (Exception)
            {
                return(Content("错误,请重试"));
            }
        }
        public ActionResult RemeoveDraw(int id)
        {
            UserInfo user = CurrentLoginUser;

            var good = GoodsServices.LoadEntities(u => u.Id == id && u.UserInfoId == user.Id).FirstOrDefault();

            good.DelGlag = normal;

            try
            {
                GoodsServices.Update(good);

                #region Lucnen创建索引
                JobSerach search = new JobSerach();
                search.Id           = good.Id;
                search.Title        = good.Title;
                search.Price        = (double)good.Price;
                search.ImageAddress = good.SmallImageAddress;
                search.Content      = good.Descript;
                search.MaiDian      = good.MaiDian;

                IndexManager.myManager.Add(search);
                #endregion

                return(Content("ok"));
            }
            catch (Exception)
            {
                return(Content("删除失败!请联系管理员"));
            }
        }
Exemplo n.º 6
0
 public StatisticServicesTest()
 {
     mapper             = new MapperConfiguration(cfg => cfg.AddProfile <Mapper> ()).CreateMapper();
     authService        = new AuthService();
     goodsService       = new GoodsServices();
     shopOrderService   = new ShopOrderService();
     typeOfGoodsService = new TypeOfGoodsService();
 }
Exemplo n.º 7
0
        public ActionResult DeleteGoods(int id)
        {
            var good = GoodsServices.LoadEntities(u => u.Id == id).FirstOrDefault();

            good.DelGlag = 0;

            GoodsServices.Update(good);

            return(Redirect("/Admin/ListGoods"));
        }
Exemplo n.º 8
0
        public ActionResult Index()
        {
            if (Session["model"] != null)
            {
                UserInfo user = Session["model"] as UserInfo;
                var      ext  = UserInfoExtServices.LoadEntities(u => u.UserInfoId == user.Id).FirstOrDefault();
                ViewData["ext"] = ext;
            }

            //获取前四名热门商品

            int total = 0;

            ViewData["SlideSales"] = GoodsServices.LoadPageEntities(1, 4, out total, u => u.DelGlag == normal, u => u.SeeCount, false).ToList();

            //获取第五名到第二十名的商品
            var sales  = GoodsServices.LoadPageEntities(2, 4, out total, u => u.DelGlag == normal, u => u.SeeCount, false).ToList();
            var sales1 = GoodsServices.LoadPageEntities(3, 4, out total, u => u.DelGlag == normal, u => u.SeeCount, false).ToList();
            var sales2 = GoodsServices.LoadPageEntities(4, 4, out total, u => u.DelGlag == normal, u => u.SeeCount, false).ToList();

            sales.AddRange(sales1);
            sales.AddRange(sales2);
            ViewData["SecondSales"] = sales;

            //获取最新商品
            ViewData["NewGoods"] = GoodsServices.LoadPageEntities(1, 11, out total, u => u.DelGlag == normal, u => u.SubTime, false).ToList();


            //获取全新商品
            ViewData["NewsGoods"] = GoodsServices.LoadPageEntities(1, 11, out total, u => u.DelGlag == normal && u.Type == News, u => u.SubTime, false).ToList();

            //获得九成新商品
            ViewData["NineGoods"] = GoodsServices.LoadPageEntities(1, 11, out total, u => u.DelGlag == normal && u.Type == Nine, u => u.SubTime, false).ToList();

            //获得八成新商品
            ViewData["EighGoods"] = GoodsServices.LoadPageEntities(1, 11, out total, u => u.DelGlag == normal && u.Type == Eigh, u => u.SubTime, false).ToList();

            //获得七成新商品
            ViewData["SevenGoods"] = GoodsServices.LoadPageEntities(1, 11, out total, u => u.DelGlag == normal && u.Type == Seven, u => u.SubTime, false).ToList();

            //获得六成新商品
            ViewData["SixGoods"] = GoodsServices.LoadPageEntities(1, 11, out total, u => u.DelGlag == normal && u.Type == Six, u => u.SubTime, false).ToList();

            //获得其它商品
            ViewData["OthersGoods"] = GoodsServices.LoadPageEntities(1, 11, out total, u => u.DelGlag == normal && u.Type == Others, u => u.SubTime, false).ToList();

            ViewData["FriendLink"] = FriendLinkServices.LoadEntities(u => true).ToList();



            return(View());
        }
Exemplo n.º 9
0
        public ActionResult ShowGoods(int?id)
        {
            #region 浏览量控制
            Goods oldgoods = GoodsServices.LoadEntities(u => u.Id == id).FirstOrDefault();
            oldgoods.SeeCount = oldgoods.SeeCount + 1;
            GoodsServices.Update(oldgoods);
            #endregion

            #region 如果已登录用户添加足迹
            if (Session["model"] != null)
            {
                UserInfo user = (UserInfo)Session["model"];

                //判断是否添加足迹到表
                MySee dbSee = MySeeServices.LoadEntities(u => u.GoodsId == id && u.UserInfoId == user.Id).FirstOrDefault();

                if (dbSee != null)
                {
                    dbSee.SubTime = DateTime.Now;
                    MySeeServices.Update(dbSee);
                }
                else
                {
                    //添加我的足迹
                    MySee see = new MySee();
                    see.GoodsId    = (int)id;
                    see.UserInfoId = ((UserInfo)Session["model"]).Id;
                    see.SubTime    = DateTime.Now;

                    MySeeServices.Add(see);
                }
            }
            #endregion

            #region 主要商品信息
            Goods good = GoodsServices.LoadEntities(u => u.Id == id && u.DelGlag == normal).FirstOrDefault();

            ViewData["Goods"] = good;

            var saleinfo = SaleInfoServices.LoadEntities(u => u.GoodsId == id).FirstOrDefault();
            ViewData["SaleInfo"] = saleinfo;
            #endregion
            int total = 0;

            var listAbout = GoodsServices.LoadPageEntities(1, 8, out total, u => u.UserInfoId == good.UserInfoId, u => u.SubTime, false).ToList();
            ViewData["AboutGoods"] = listAbout;

            ViewBag.Title = good.Title + "青职二货街";

            return(View());
        }
        public ActionResult EditGoods(Goods good, SaleInfo sale, int GoodId, int SaleId)
        {
            var oldgood = GoodsServices.LoadEntities(u => u.Id == GoodId).FirstOrDefault();

            oldgood.Title             = good.Title;
            oldgood.Price             = good.Price;
            oldgood.MaiDian           = good.MaiDian;
            oldgood.LaiYuan           = good.LaiYuan;
            oldgood.SmallImageAddress = good.SmallImageAddress;
            oldgood.BigImageAddress   = good.BigImageAddress;
            oldgood.Count             = good.Count;
            oldgood.Descript          = good.Descript;
            oldgood.Type = good.Type;
            good.Id      = GoodId;

            var oldsale = SaleInfoServices.LoadEntities(u => u.GoodsId == GoodId).FirstOrDefault();

            oldsale.PhoneNum = sale.PhoneNum;
            oldsale.QQ       = sale.QQ;
            oldsale.RealName = sale.RealName;
            oldsale.Address  = sale.Address;
            oldsale.Id       = SaleId;

            try
            {
                SaleInfoServices.Update(oldsale);

                GoodsServices.Update(oldgood);

                #region Luncene创建索引
                JobSerach search = new JobSerach();
                search.Id           = good.Id;
                search.Title        = good.Title;
                search.Price        = (double)good.Price;
                search.ImageAddress = good.SmallImageAddress;
                search.Content      = good.Descript;
                search.MaiDian      = good.MaiDian;

                IndexManager.myManager.Add(search);
                #endregion

                return(Content("信息更新成功"));
            }
            catch (Exception)
            {
                return(Content("信息更新失败,请按照格式输入"));
            }
        }
        public ActionResult AddGoods(Goods good, SaleInfo sale)
        {
            UserInfo user = CurrentLoginUser;

            if (user == null)
            {
                return(Redirect("/Account/login"));
            }

            good.DelGlag = normal;
            good.SubTime = DateTime.Now;

            var shops = ListShopsServices.LoadEntities(u => u.UserInfoId == CurrentLoginUser.Id).FirstOrDefault();

            good.ShopingId = shops.Id;

            try
            {
                GoodsServices.Add(user, good, sale);

                #region Luncene创建索引
                JobSerach search = new JobSerach();
                search.Id           = good.Id;
                search.Title        = good.Title;
                search.Price        = (double)good.Price;
                search.ImageAddress = good.SmallImageAddress;
                search.Content      = good.Descript;
                search.MaiDian      = good.MaiDian;

                IndexManager.myManager.Add(search);
                #endregion



                return(Content("ok"));
            }
            catch (Exception)
            {
                return(Content("数据错误,请联系管理员"));

                throw;
            }
        }
        public ActionResult DeleteGoods(int id)
        {
            UserInfo user = CurrentLoginUser;

            var good = GoodsServices.LoadEntities(u => u.Id == id && u.UserInfoId == user.Id).FirstOrDefault();

            good.DelGlag = delete;

            try
            {
                GoodsServices.Update(good);
                IndexManager.myManager.Delete(good.Id);
                return(Content("ok"));
            }
            catch (Exception)
            {
                return(Content("删除失败!请联系管理员"));

                throw;
            }
        }
        public ActionResult DrawBack(int?pageIndex)
        {
            if (IsOpenShops())
            {
                ViewData["message"] = "1";
                if (pageIndex == null)
                {
                    pageIndex = 1;
                }

                UserInfo user = CurrentLoginUser;

                if (user == null)
                {
                    return(Redirect("/Account/Login"));
                }

                int total = 0;
                var goods = GoodsServices.LoadPageEntities((int)pageIndex, 5, out total, u => u.DelGlag == delete && u.UserInfoId == user.Id, o => o.Id, true).AsQueryable();

                if (goods == null)
                {
                    return(Content("数据库数据错误!请联系管理员"));
                }

                ViewData["allGoods"] = goods;

                ViewData["pageIndex"] = pageIndex;

                ViewData["Count"] = total;
            }
            else
            {
                ViewData["message"] = "0";
            }
            return(View());
        }
        public ActionResult Home(int?pageindex)
        {
            if (pageindex == null || pageindex < 1)
            {
                pageindex = 1;
            }

            //未读消息数量
            int weiduNews = MyNewsServices.LoadEntities(u => u.IsSee == noSeeMyNews && u.UserInfoId == CurrentLoginUser.Id).Count();

            ViewData["weiduNews"] = weiduNews;

            ViewData.Model = CurrentLoginUser;

            var userext = UserInfoExtServices.LoadEntities(u => u.UserInfoId == CurrentLoginUser.Id).FirstOrDefault();

            ViewData["userext"] = userext;

            int total = 0;
            IQueryable <Goods> good = GoodsServices.LoadPageEntities((int)pageindex, 9, out total, u => u.DelGlag == normal, u => u.Id, false);

            ViewData["RandGoods"] = good;
            return(View());
        }
Exemplo n.º 15
0
        public ActionResult ListGoods()
        {
            ViewData.Model = GoodsServices.LoadEntities(u => u.DelGlag == deleteNo);

            return(View());
        }
Exemplo n.º 16
0
 public ActionResult DetailsGoods(int id)
 {
     ViewData.Model = GoodsServices.LoadEntities(u => u.Id == id).FirstOrDefault();
     return(View());
 }
Exemplo n.º 17
0
 public GoodsController(GoodsServices services)
 {
     this.services = services;
 }
Exemplo n.º 18
0
        public ActionResult Search(string key, int?pageIndex)
        {
            if (key == null)
            {
                key = "";
            }

            #region 侧边栏和底部栏目
            //获取前五名热门商品

            int total = 0;
            ViewData["SlideSales"] = GoodsServices.LoadPageEntities(1, 5, out total, u => u.DelGlag == normal, u => u.SeeCount, false).ToList();

            //获取相关商品
            var   listGoods = GoodsServices.LoadEntities(u => u.DelGlag == normal).ToList();
            int   length    = listGoods.Count();
            int[] goodid    = new int[length];

            for (int i = 0; i < listGoods.Count(); i++)
            {
                goodid[i] = listGoods[i].Id;
            }


            Random       rand      = new Random();
            List <Goods> listAbout = new List <Goods>();

            if (listGoods.Count > 1)
            {
                for (int i = 0; i < 5; i++)
                {
                    int   id   = rand.Next(0, listGoods.Count());
                    Goods good = GoodsServices.LoadEntities(u => u.Id == goodid[id]).FirstOrDefault();
                    listAbout.Add(good);
                }
            }

            ViewData["listAbout"] = listAbout;
            #endregion

            #region 搜索部分
            ViewData["key"] = key;

            if (pageIndex == null)
            {
                pageIndex = 1;
            }
            ViewData["pageIndex"] = pageIndex;

            List <JobSerach> list = new List <JobSerach>();

            if (!string.IsNullOrEmpty(key))
            {
                int index = ((int)pageIndex - 1) * 16 + 1;
                list = LunceneHelper.SearchContent(key, index, 16);
                ViewData["searchs"] = list;
            }
            ViewData["searchs"] = list;

            list = LunceneHelper.SearchContent(key);

            ViewData["Count"] = list.Count();
            #endregion

            return(View());
        }
Exemplo n.º 19
0
 public GoodsServicesTest()
 {
     mapper  = new MapperConfiguration(cfg => cfg.AddProfile <Mapper> ()).CreateMapper();
     service = new GoodsServices();
 }
Exemplo n.º 20
0
 public ActionResult EditGoods(Goods goods)
 {
     GoodsServices.Update(goods);
     return(Redirect("/Admin/ListGoods"));
 }