예제 #1
0
 public string Update(Collect c)
 {
     YogaEntities ey = new YogaEntities();
     Collect cc = ey.Collect.FirstOrDefault((ccc) => ccc.Id == c.Id);
     if (cc == null) return string.Format("编号为{0}的商品不存在", c.Id);
     cc.GoodsId = c.GoodsId;
     return ey.SaveChanges() == 1 ? "成功" : "失败";
 }
예제 #2
0
 public Collect[] Search(Collect c, DateTime dateStart, DateTime dateEnd, ref int page, int pageSize, out int totalPages)
 {
     YogaEntities ey = new YogaEntities();
     var query = from cc in ey.Collect where cc.Datie >= dateStart && cc.Datie <= dateEnd select cc;
     if (c.Id > 0) query = query.Where((cc) => cc.Id == c.Id);
     if (c.GoodsId > 0) query = query.Where((cc) => cc.GoodsId == c.GoodsId);
     totalPages = (int)Math.Ceiling(query.Count() * 1.0 / pageSize);
     if (totalPages < 1)
     {
         page = 0;
         return null;
     }
     if (page == -1 || page > totalPages) page = totalPages;
     else if (page < 1) page = 1;
     return query.OrderBy((cc) => cc.Id).Skip((page - 1) * pageSize).Take(pageSize).ToArray();
 }
예제 #3
0
 /// <summary>
 /// Create a new Collect object.
 /// </summary>
 /// <param name="id">Initial value of the Id property.</param>
 /// <param name="datie">Initial value of the Datie property.</param>
 /// <param name="goodsId">Initial value of the GoodsId property.</param>
 /// <param name="memberId">Initial value of the MemberId property.</param>
 /// <param name="userId">Initial value of the UserId property.</param>
 public static Collect CreateCollect(global::System.Int32 id, global::System.DateTime datie, global::System.Int32 goodsId, global::System.Int32 memberId, global::System.Int32 userId)
 {
     Collect collect = new Collect();
     collect.Id = id;
     collect.Datie = datie;
     collect.GoodsId = goodsId;
     collect.MemberId = memberId;
     collect.UserId = userId;
     return collect;
 }
예제 #4
0
 /// <summary>
 /// Deprecated Method for adding a new object to the Collect EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToCollect(Collect collect)
 {
     base.AddObject("Collect", collect);
 }
예제 #5
0
 public int Add(Collect a)
 {
     YogaEntities ey = new YogaEntities();
     ey.AddToCollect(a);
     return ey.SaveChanges() == 1 ? a.Id : -1;
 }