public async Task <IActionResult> PutShopcart([FromRoute] int id, [FromBody] Shopcart shopcart)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != shopcart.CartId)
            {
                return(BadRequest());
            }

            _context.Entry(shopcart).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ShopcartExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
        public async Task <IActionResult> PostShopcart([FromBody] Shopcart shopcart)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _context.Shopcart.Add(shopcart);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetShopcart", new { id = shopcart.CartId }, shopcart));
        }
Exemple #3
0
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddSingleton <IHttpContextAccessor, HttpContextAccessor>();
            services.AddScoped(sp => Shopcart.GetCart(sp));

            services.AddDbContext <AppDBContent>(options => options.UseSqlServer(_confString.GetConnectionString("DefaultConnection")));
            services.AddMvc();
            services.AddTransient <IAllCars, CarRepository>();
            services.AddTransient <ICarsCategory, CategoryRepository>();
            services.AddTransient <IAllOrders, OrdersRepository>();

            services.AddMemoryCache();
            services.AddSession();
        }
Exemple #4
0
 public ActionResult AddToShopCart(int uid, int proid, int num)
 {
     try
     {
         User u = db.User.ToList().Where(n => (n.Uid == uid)).SingleOrDefault();
         if (u != null)
         {
             //购物车中是否存在该物品
             Shopcart cart = db.Shopcart.Where(n => n.ProId == proid && n.Uid == u.Uid).SingleOrDefault();
             //存在就添加数量
             if (cart != null)
             {
                 cart.Num += num;
                 db.SaveChanges();
             }
             //否则就新增
             else
             {
                 cart       = new Shopcart();
                 cart.Uid   = u.Uid;
                 cart.Num   = num;
                 cart.ProId = proid;
                 db.Shopcart.Add(cart);
                 db.SaveChanges();
             }
             return(Ok("添加成功"));
         }
         else
         {
             return(BadRequest());
         }
     }
     catch (Exception ex)
     {
         return(NotFound(ex.Message));
     }
 }
        /// <summary>
        /// 加入购物车方法
        /// </summary>
        /// <returns></returns>
        public ResultJson AddCartFunc(UpdateCartInfoRequest request)
        {
            #region 未登入用户登入
            if (!request.Moblie.IsNullOrEmpty() && !request.VaildCode.IsNullOrEmpty())
            {
                LoginByPhoneRequest loginByPhoneRequest = new LoginByPhoneRequest();
                loginByPhoneRequest.IsThild   = true;
                loginByPhoneRequest.UserPhone = request.Moblie;
                loginByPhoneRequest.PhoneCode = request.VaildCode;
                HomeController controller  = new HomeController();
                var            resultLogin = controller.LoginByPhone(loginByPhoneRequest);
                if (resultLogin.HttpCode != 200)
                {
                    return(new ResultJson {
                        HttpCode = resultLogin.HttpCode, Message = resultLogin.Message
                    });
                }
            }
            #endregion

            if (request.ShopCartId == 0)
            {
                var      Hisdesign = GetHisdesign(request.CommodityId, request.userGuid);
                Shopcart shopcart  = new Shopcart
                {
                    UserID         = Hisdesign.UserID,
                    UserGuId       = Hisdesign.UserGuid,
                    CommodityId    = Hisdesign.CommodityId,
                    BackContent    = Hisdesign.BackContent,
                    ForntContent   = Hisdesign.ForntContent,
                    BackView       = Hisdesign.BackView,
                    ForntView      = Hisdesign.ForntView,
                    LastLookTime   = DateTime.Now,
                    Color          = request.Color,
                    PrintingMethod = request.PrintingMethod,
                    Attr           = request.Attr,
                    Amount         = request.Amount,
                    IsMobile       = false
                };
                if (ShopCartFunc.Instance.InsertShopCart(shopcart))
                {
                    #region 图片复制,没用的图片删除
                    shopcart = ShopCartFunc.Instance.SelectShopCart(shopcart);
                    if (request.ListImg != null)
                    {
                        var ImgArry = request.ListImg.Split(',');
                        foreach (var item in ImgArry)
                        {
                            if (!item.IsNullOrEmpty())
                            {
                                shopcart.BackContent  = shopcart.BackContent.Replace(item, $"/current/images/ShopCart/{ shopcart.Id}/" + item.Split('/').Last());
                                shopcart.ForntContent = shopcart.ForntContent.Replace(item, $"/current/images/ShopCart/{ shopcart.Id}/" + item.Split('/').Last());
                                FileHelper.Instance.Move(FileUrl + item, FileUrl + $"/current/images/ShopCart/{ shopcart.Id}/" + item.Split('/').Last(), FileUrl + $"/current/images/ShopCart/{ shopcart.Id}/");
                            }
                        }
                        if (!shopcart.BackView.IsNullOrEmpty())
                        {
                            FileHelper.Instance.Move(FileUrl + shopcart.BackView, FileUrl + $"/current/images/ShopCart/{ shopcart.Id}/Back/" + shopcart.BackView.Split('/').Last(), FileUrl + $"/current/images/ShopCart/{ shopcart.Id}/Back/");
                            shopcart.BackView = $"/current/images/ShopCart/{ shopcart.Id}/Back/" + shopcart.BackView.Split('/').Last();
                        }
                        if (!shopcart.ForntView.IsNullOrEmpty())
                        {
                            FileHelper.Instance.Move(FileUrl + shopcart.ForntView, FileUrl + $"/current/images/ShopCart/{ shopcart.Id}/Fornt/" + shopcart.ForntView.Split('/').Last(), FileUrl + $"/current/images/ShopCart/{ shopcart.Id}/Fornt/");
                            shopcart.ForntView = $"/current/images/ShopCart/{ shopcart.Id}/Fornt/" + shopcart.ForntView.Split('/').Last();
                        }
                        FileHelper.Instance.DelectDir(FileUrl + $"/current/images/Order/{ Hisdesign.Id}/");
                    }
                    #endregion

                    #region 更新购物车的前图与后图,删除历史设计信息
                    ShopCartFunc.Instance.UpdateShopCart(shopcart);
                    HisdesignFunc.Instance.DeleteHisdesignById(Hisdesign.Id);
                    #endregion
                    return(new ResultJson {
                        HttpCode = 200, Message = shopcart.Id.ToString()
                    });
                }
                return(new ResultJson {
                    HttpCode = 300, Message = "插入不成功!"
                });
            }
            else
            {
                var shopcart = GetShopCart(request.ShopCartId);
                shopcart.Color          = request.Color;
                shopcart.PrintingMethod = request.PrintingMethod;
                shopcart.Attr           = request.Attr;
                shopcart.Amount         = request.Amount;
                if (ShopCartFunc.Instance.UpdateShopCart(shopcart))
                {
                    #region 图片复制,没用的图片删除
                    if (request.ListImg != null && request.ListImg != "")
                    {
                        var ImgArry = request.ListImg.Split(',').Where(p => p != "" && p != null).ToList();
                        foreach (var item in ImgArry)
                        {
                            if (!item.IsNullOrEmpty())
                            {
                                FileHelper.Instance.DelectDirWithOutList($"/current/images/Order/{ shopcart.Id}/", ImgArry, FileUrl);
                            }
                        }
                    }

                    #endregion

                    return(new ResultJson {
                        HttpCode = 200, Message = request.ShopCartId.ToString()
                    });
                }
                return(new ResultJson {
                    HttpCode = 300, Message = "插入不成功!"
                });
            }
        }
 /// <summary>
 /// 数据条数
 /// </summary>
 /// <param name="model">模型</param>
 /// <returns>对象列表</returns>
 public int SelectCount(Shopcart model)
 {
     return(ShopcartOper.Instance.SelectCount(model));
 }
 /// <summary>
 /// 筛选全部数据
 /// </summary>
 /// <param name="model">模型</param>
 /// <returns>对象列表</returns>
 public List <Shopcart> SelectByModel(Shopcart model)
 {
     return(ShopcartOper.Instance.SelectAll(model));
 }
 /// <summary>
 /// 根据模型插入
 /// </summary>
 /// <param name="model">模型</param>
 /// <returns>是否成功</returns>
 public int InsertReturnKey(Shopcart model)
 {
     return(ShopcartOper.Instance.InsertReturnKey(model));
 }
Exemple #9
0
        /// <summary>
        /// 根据分页筛选数据
        /// </summary>
        /// <param name="Key">主键</param>
        /// <param name="start">开始数据</param>
        /// <param name="PageSize">页面长度</param>
        /// <param name="desc">排序</param>
        /// <param name="model">对象</param>
        /// <param name="connection">连接</param>
        /// <param name="transaction">事务</param>
        /// <returns>对象列表</returns>
        public List <Shopcart> SelectByPage(string Key, int start, int PageSize, bool desc = true, Shopcart model = null, string SelectFiled = null, IDbConnection connection = null, IDbTransaction transaction = null)
        {
            var query = new LambdaQuery <Shopcart>();

            if (model != null)
            {
                if (!model.Id.IsNullOrEmpty())
                {
                    query.Where(p => p.Id == model.Id);
                }
                if (!model.UserID.IsNullOrEmpty())
                {
                    query.Where(p => p.UserID == model.UserID);
                }
                if (!model.UserGuId.IsNullOrEmpty())
                {
                    query.Where(p => p.UserGuId == model.UserGuId);
                }
                if (!model.CommodityId.IsNullOrEmpty())
                {
                    query.Where(p => p.CommodityId == model.CommodityId);
                }
                if (!model.BackContent.IsNullOrEmpty())
                {
                    query.Where(p => p.BackContent == model.BackContent);
                }
                if (!model.ForntContent.IsNullOrEmpty())
                {
                    query.Where(p => p.ForntContent == model.ForntContent);
                }
                if (!model.BackView.IsNullOrEmpty())
                {
                    query.Where(p => p.BackView == model.BackView);
                }
                if (!model.ForntView.IsNullOrEmpty())
                {
                    query.Where(p => p.ForntView == model.ForntView);
                }
                if (!model.LastLookTime.IsNullOrEmpty())
                {
                    query.Where(p => p.LastLookTime == model.LastLookTime);
                }
                if (!model.Color.IsNullOrEmpty())
                {
                    query.Where(p => p.Color == model.Color);
                }
                if (!model.PrintingMethod.IsNullOrEmpty())
                {
                    query.Where(p => p.PrintingMethod == model.PrintingMethod);
                }
                if (!model.Attr.IsNullOrEmpty())
                {
                    query.Where(p => p.Attr == model.Attr);
                }
                if (!model.Amount.IsNullOrEmpty())
                {
                    query.Where(p => p.Amount == model.Amount);
                }
                if (!model.OrderId.IsNullOrEmpty())
                {
                    query.Where(p => p.OrderId == model.OrderId);
                }
                if (!model.IsMobile.IsNullOrEmpty())
                {
                    query.Where(p => p.IsMobile == model.IsMobile);
                }
            }
            if (SelectFiled != null)
            {
                SelectFiled = SelectFiled.ToLowerInvariant();
                if (SelectFiled.Contains("id,"))
                {
                    query.Select(p => new { p.Id });
                }
                if (SelectFiled.Contains("userid,"))
                {
                    query.Select(p => new { p.UserID });
                }
                if (SelectFiled.Contains("userguid,"))
                {
                    query.Select(p => new { p.UserGuId });
                }
                if (SelectFiled.Contains("commodityid,"))
                {
                    query.Select(p => new { p.CommodityId });
                }
                if (SelectFiled.Contains("backcontent,"))
                {
                    query.Select(p => new { p.BackContent });
                }
                if (SelectFiled.Contains("forntcontent,"))
                {
                    query.Select(p => new { p.ForntContent });
                }
                if (SelectFiled.Contains("backview,"))
                {
                    query.Select(p => new { p.BackView });
                }
                if (SelectFiled.Contains("forntview,"))
                {
                    query.Select(p => new { p.ForntView });
                }
                if (SelectFiled.Contains("lastlooktime,"))
                {
                    query.Select(p => new { p.LastLookTime });
                }
                if (SelectFiled.Contains("color,"))
                {
                    query.Select(p => new { p.Color });
                }
                if (SelectFiled.Contains("printingmethod,"))
                {
                    query.Select(p => new { p.PrintingMethod });
                }
                if (SelectFiled.Contains("attr,"))
                {
                    query.Select(p => new { p.Attr });
                }
                if (SelectFiled.Contains("amount,"))
                {
                    query.Select(p => new { p.Amount });
                }
                if (SelectFiled.Contains("orderid,"))
                {
                    query.Select(p => new { p.OrderId });
                }
                if (SelectFiled.Contains("ismobile,"))
                {
                    query.Select(p => new { p.IsMobile });
                }
            }
            if (Key != null)
            {
                query.OrderByKey(Key, desc);
            }
            return(query.GetQueryPageList(start, PageSize, connection, transaction));
        }
Exemple #10
0
        /// <summary>
        /// 根据模型插入
        /// </summary>
        /// <param name="model">模型</param>
        /// <param name="connection">连接</param>
        /// <param name="transaction">事务</param>
        /// <returns>是否成功</returns>
        public int InsertReturnKey(Shopcart model, IDbConnection connection = null, IDbTransaction transaction = null)
        {
            var insert = new LambdaInsert <Shopcart>();

            if (!model.UserID.IsNullOrEmpty())
            {
                insert.Insert(p => p.UserID == model.UserID);
            }
            if (!model.UserGuId.IsNullOrEmpty())
            {
                insert.Insert(p => p.UserGuId == model.UserGuId);
            }
            if (!model.CommodityId.IsNullOrEmpty())
            {
                insert.Insert(p => p.CommodityId == model.CommodityId);
            }
            if (!model.BackContent.IsNullOrEmpty())
            {
                insert.Insert(p => p.BackContent == model.BackContent);
            }
            if (!model.ForntContent.IsNullOrEmpty())
            {
                insert.Insert(p => p.ForntContent == model.ForntContent);
            }
            if (!model.BackView.IsNullOrEmpty())
            {
                insert.Insert(p => p.BackView == model.BackView);
            }
            if (!model.ForntView.IsNullOrEmpty())
            {
                insert.Insert(p => p.ForntView == model.ForntView);
            }
            if (!model.LastLookTime.IsNullOrEmpty())
            {
                insert.Insert(p => p.LastLookTime == model.LastLookTime);
            }
            if (!model.Color.IsNullOrEmpty())
            {
                insert.Insert(p => p.Color == model.Color);
            }
            if (!model.PrintingMethod.IsNullOrEmpty())
            {
                insert.Insert(p => p.PrintingMethod == model.PrintingMethod);
            }
            if (!model.Attr.IsNullOrEmpty())
            {
                insert.Insert(p => p.Attr == model.Attr);
            }
            if (!model.Amount.IsNullOrEmpty())
            {
                insert.Insert(p => p.Amount == model.Amount);
            }
            if (!model.OrderId.IsNullOrEmpty())
            {
                insert.Insert(p => p.OrderId == model.OrderId);
            }
            if (!model.IsMobile.IsNullOrEmpty())
            {
                insert.Insert(p => p.IsMobile == model.IsMobile);
            }
            return(insert.GetInsertResult(connection, transaction));
        }
 /// <summary>
 /// 根据分页筛选数据
 /// </summary>
 /// <param name="Key">主键</param>
 /// <param name="start">开始数据</param>
 /// <param name="PageSize">页面长度</param>
 /// <param name="desc">排序</param>
 /// <param name="model">对象</param>
 /// <returns>对象列表</returns>
 public List <Shopcart> SelectByPage(string Key, int start, int PageSize, bool desc, Shopcart model, string SelectFiled)
 {
     return(ShopcartOper.Instance.SelectByPage(Key, start, PageSize, desc, model));
 }
Exemple #12
0
 public ShopcartController(IAllCars allCars, Shopcart cart)
 {
     _icars    = allCars;
     _shopcart = cart;
 }
Exemple #13
0
 /// <summary>
 /// 筛选购物车信息
 /// </summary>
 /// <param name="model">模型</param>
 /// <returns></returns>
 public Shopcart SelectShopCart(Shopcart model)
 {
     return(ShopcartOper.Instance.SelectAll(model).FirstOrDefault());
 }
Exemple #14
0
 public OrdersRepository(AppDBContent appDBContent, Shopcart shopcart)
 {
     this.appDBContent = appDBContent;
     this.shopcart     = shopcart;
 }
Exemple #15
0
        /// <summary>
        /// 加入购物车方法
        /// </summary>
        /// <returns></returns>
        public ResultJson AddCartFunc(UpdateCartInfoRequest request)
        {
            if (request.ShopCartId == 0)
            {
                var      Hisdesign = GetHisdesign(request.CommodityId, request.userGuid);
                Shopcart shopcart  = new Shopcart
                {
                    UserID         = Hisdesign.UserID,
                    UserGuId       = Hisdesign.UserGuid,
                    CommodityId    = Hisdesign.CommodityId,
                    BackContent    = Hisdesign.BackContent,
                    ForntContent   = Hisdesign.ForntContent,
                    BackView       = Hisdesign.BackView,
                    ForntView      = Hisdesign.ForntView,
                    LastLookTime   = DateTime.Now,
                    Color          = request.Color,
                    PrintingMethod = request.PrintingMethod,
                    Attr           = request.Attr,
                    Amount         = request.Amount,
                    IsMobile       = request.PayType == "moblie"
                };
                if (ShopCartFunc.Instance.InsertShopCart(shopcart))
                {
                    #region 图片复制,没用的图片删除
                    shopcart = ShopCartFunc.Instance.SelectShopCart(shopcart);
                    if (request.ListImg != null)
                    {
                        var ImgArry = request.ListImg.Split(',');
                        foreach (var item in ImgArry)
                        {
                            if (!item.IsNullOrEmpty())
                            {
                                shopcart.BackContent  = shopcart.BackContent.Replace(item, $"/current/images/ShopCart/{ shopcart.Id}/" + item.Split('/').Last());
                                shopcart.ForntContent = shopcart.ForntContent.Replace(item, $"/current/images/ShopCart/{ shopcart.Id}/" + item.Split('/').Last());
                                FileHelper.Instance.Move(HttpContext.Current.Server.MapPath(item), HttpContext.Current.Server.MapPath($"/current/images/ShopCart/{ shopcart.Id}/" + item.Split('/').Last()), HttpContext.Current.Server.MapPath($"/current/images/ShopCart/{ shopcart.Id}/"));
                            }
                        }
                        if (!shopcart.BackView.IsNullOrEmpty())
                        {
                            FileHelper.Instance.Move(HttpContext.Current.Server.MapPath(shopcart.BackView), HttpContext.Current.Server.MapPath($"/current/images/ShopCart/{ shopcart.Id}/Back/" + shopcart.BackView.Split('/').Last()), HttpContext.Current.Server.MapPath($"/current/images/ShopCart/{ shopcart.Id}/Back/"));
                            shopcart.BackView = $"/current/images/ShopCart/{ shopcart.Id}/Back/" + shopcart.BackView.Split('/').Last();
                        }
                        if (!shopcart.ForntView.IsNullOrEmpty())
                        {
                            FileHelper.Instance.Move(HttpContext.Current.Server.MapPath(shopcart.ForntView), HttpContext.Current.Server.MapPath($"/current/images/ShopCart/{ shopcart.Id}/Fornt/" + shopcart.ForntView.Split('/').Last()), HttpContext.Current.Server.MapPath($"/current/images/ShopCart/{ shopcart.Id}/Fornt/"));
                            shopcart.ForntView = $"/current/images/ShopCart/{ shopcart.Id}/Fornt/" + shopcart.ForntView.Split('/').Last();
                        }
                        FileHelper.Instance.DelectDir(HttpContext.Current.Server.MapPath($"/current/images/ShopCart/{ Hisdesign.Id}/"));
                    }
                    #endregion

                    #region 更新购物车的前图与后图,删除历史设计信息
                    ShopCartFunc.Instance.UpdateShopCart(shopcart);
                    HisdesignFunc.Instance.DeleteHisdesignById(Hisdesign.Id);
                    #endregion
                    return(new ResultJson {
                        HttpCode = 200, Message = shopcart.Id.ToString()
                    });
                }
                return(new ResultJson {
                    HttpCode = 300, Message = "插入不成功!"
                });
            }
            else
            {
                var shopcart = GetShopCart(request.ShopCartId);
                shopcart.Color          = request.Color;
                shopcart.PrintingMethod = request.PrintingMethod;
                shopcart.Attr           = request.Attr;
                shopcart.Amount         = request.Amount;
                if (ShopCartFunc.Instance.UpdateShopCart(shopcart))
                {
                    #region 图片复制,没用的图片删除
                    var ImgArry = request.ListImg.Split(',').Where(p => p != "" && p != null).ToList();
                    foreach (var item in ImgArry)
                    {
                        if (!item.IsNullOrEmpty())
                        {
                            FileHelper.Instance.DelectDirWithOutList($"/current/images/ShopCart/{ shopcart.Id}/", ImgArry);
                        }
                    }
                    #endregion

                    return(new ResultJson {
                        HttpCode = 200, Message = "程序执行成功!"
                    });
                }
                return(new ResultJson {
                    HttpCode = 300, Message = "插入不成功!"
                });
            }
        }
Exemple #16
0
        /// <summary>
        /// 根据模型更新
        /// </summary>
        /// <param name="model">模型</param>
        /// <param name="connection">连接</param>
        /// <param name="transaction">事务</param>
        /// <returns>是否成功</returns>
        public bool Update(Shopcart model, IDbConnection connection = null, IDbTransaction transaction = null)
        {
            var update = new LambdaUpdate <Shopcart>();

            if (!model.Id.IsNullOrEmpty())
            {
                update.Where(p => p.Id == model.Id);
            }
            if (!model.UserID.IsNullOrEmpty())
            {
                update.Set(p => p.UserID == model.UserID);
            }
            if (!model.UserGuId.IsNullOrEmpty())
            {
                update.Set(p => p.UserGuId == model.UserGuId);
            }
            if (!model.CommodityId.IsNullOrEmpty())
            {
                update.Set(p => p.CommodityId == model.CommodityId);
            }
            if (!model.BackContent.IsNullOrEmpty())
            {
                update.Set(p => p.BackContent == model.BackContent);
            }
            if (!model.ForntContent.IsNullOrEmpty())
            {
                update.Set(p => p.ForntContent == model.ForntContent);
            }
            if (!model.BackView.IsNullOrEmpty())
            {
                update.Set(p => p.BackView == model.BackView);
            }
            if (!model.ForntView.IsNullOrEmpty())
            {
                update.Set(p => p.ForntView == model.ForntView);
            }
            if (!model.LastLookTime.IsNullOrEmpty())
            {
                update.Set(p => p.LastLookTime == model.LastLookTime);
            }
            if (!model.Color.IsNullOrEmpty())
            {
                update.Set(p => p.Color == model.Color);
            }
            if (!model.PrintingMethod.IsNullOrEmpty())
            {
                update.Set(p => p.PrintingMethod == model.PrintingMethod);
            }
            if (!model.Attr.IsNullOrEmpty())
            {
                update.Set(p => p.Attr == model.Attr);
            }
            if (!model.Amount.IsNullOrEmpty())
            {
                update.Set(p => p.Amount == model.Amount);
            }
            if (!model.OrderId.IsNullOrEmpty())
            {
                update.Set(p => p.OrderId == model.OrderId);
            }
            if (!model.IsMobile.IsNullOrEmpty())
            {
                update.Set(p => p.IsMobile == model.IsMobile);
            }
            return(update.GetUpdateResult(connection, transaction));
        }
 /// <summary>
 /// 根据模型删除数据
 /// </summary>
 /// <param name="model">模型</param>
 /// <returns>是否成功</returns>
 public bool DeleteModel(Shopcart model)
 {
     return(ShopcartOper.Instance.DeleteModel(model));
 }
Exemple #18
0
        /// <summary>
        /// 数据条数
        /// </summary>
        /// <param name="model">模型</param>
        /// <param name="connection">连接</param>
        /// <param name="transaction">事务</param>
        /// <returns>对象列表</returns>
        public int SelectCount(Shopcart model = null, IDbConnection connection = null, IDbTransaction transaction = null)
        {
            var query = new LambdaQuery <Shopcart>();

            if (model != null)
            {
                if (!model.Id.IsNullOrEmpty())
                {
                    query.Where(p => p.Id == model.Id);
                }
                if (!model.UserID.IsNullOrEmpty())
                {
                    query.Where(p => p.UserID == model.UserID);
                }
                if (!model.UserGuId.IsNullOrEmpty())
                {
                    query.Where(p => p.UserGuId == model.UserGuId);
                }
                if (!model.CommodityId.IsNullOrEmpty())
                {
                    query.Where(p => p.CommodityId == model.CommodityId);
                }
                if (!model.BackContent.IsNullOrEmpty())
                {
                    query.Where(p => p.BackContent == model.BackContent);
                }
                if (!model.ForntContent.IsNullOrEmpty())
                {
                    query.Where(p => p.ForntContent == model.ForntContent);
                }
                if (!model.BackView.IsNullOrEmpty())
                {
                    query.Where(p => p.BackView == model.BackView);
                }
                if (!model.ForntView.IsNullOrEmpty())
                {
                    query.Where(p => p.ForntView == model.ForntView);
                }
                if (!model.LastLookTime.IsNullOrEmpty())
                {
                    query.Where(p => p.LastLookTime == model.LastLookTime);
                }
                if (!model.Color.IsNullOrEmpty())
                {
                    query.Where(p => p.Color == model.Color);
                }
                if (!model.PrintingMethod.IsNullOrEmpty())
                {
                    query.Where(p => p.PrintingMethod == model.PrintingMethod);
                }
                if (!model.Attr.IsNullOrEmpty())
                {
                    query.Where(p => p.Attr == model.Attr);
                }
                if (!model.Amount.IsNullOrEmpty())
                {
                    query.Where(p => p.Amount == model.Amount);
                }
                if (!model.OrderId.IsNullOrEmpty())
                {
                    query.Where(p => p.OrderId == model.OrderId);
                }
                if (!model.IsMobile.IsNullOrEmpty())
                {
                    query.Where(p => p.IsMobile == model.IsMobile);
                }
            }
            return(query.GetQueryCount(connection, transaction));
        }
 /// <summary>
 /// 根据模型更新
 /// </summary>
 /// <param name="model">模型</param>
 /// <returns>是否成功</returns>
 public bool Update(Shopcart model)
 {
     return(ShopcartOper.Instance.Update(model));
 }
 /// <summary>
 /// 根据模型插入
 /// </summary>
 /// <param name="model">模型</param>
 /// <returns>是否成功</returns>
 public bool Insert(Shopcart model)
 {
     return(ShopcartOper.Instance.Insert(model));
 }
Exemple #21
0
 public OrderController(IAllOrders allOrders, Shopcart shopcart)
 {
     this.allOrders = allOrders;
     this.shopcart  = shopcart;
 }