public IQueryable<Item> ItemGetByBuyer(IQueryable<Item> items, User buyer) { return from ord in yikuData.Orders where ord.UID == buyer.UID && items.Contains(ord.Item) orderby ord.OrID select ord.Item; }
public UserCreateStatus UserCreate(string name, string password, string address, string consignee, string tel, string zipcode, bool overwrite = false) { try { User user = GetUser(name); if (user != null) { if (!overwrite) return UserCreateStatus.AlreadyExist; if (password != null) user.PSW = password; if (address != null) user.Address = address; if (consignee != null) user.Consignee = consignee; if (tel != null) user.Tel = tel; if (zipcode != null) user.ZipCode = zipcode; } else { user = new User(); user.PSW = password; user.Name = name; user.Address = address; user.Consignee = consignee; user.Tel = tel; user.ZipCode = zipcode; user.ROLE = "User"; user.Exist = true; Add(user); } return UserCreateStatus.Succeed; } catch{ return UserCreateStatus.Faild; } }
public ActionResult profile(User user) { UpdateModel(yikuData.UserCurrent); yikuData.Save(); ViewData["MyYiku"] = "profile"; return View(yikuData.UserCurrent); }
public bool UserChangePassword(User user, string pswOld, string pswNew) { if (UserExist(user) && user.PSW.Trim() == pswOld) { user.PSW = pswNew; return true; } return false; }
//T_Collection Set public T_Collection AddCollection(User user, Item item) { T_Collection tco = GetT_Collection(item, user); if (tco == null) tco = new T_Collection(); else return tco; tco.UID = user.UID; tco.IID = item.IID; Add(tco); return tco; }
public Order OrderCreate(User user, Item item, string Cut, int count = 1) { Order order = new Order(); order.UID = user.UID; order.IID = item.IID; order.Count = count; order.Cut = Cut; order.Time = DateTime.Now; order.Cost = item.Price * count; order.State = "buy"; Add(order); return order; }
public T_Shopping DeleteShopping(User user, Item item, int count) { T_Shopping tsh = GetT_Shopping(item, user); if (tsh != null) { if (tsh.Count <= count) Delete(tsh); else { tsh.Count -= count; return tsh; } } return null; }
public Item ItemCreate(User publisher, string name, string detail, int stock, decimal price, string cutType) { Item item = new Item(); item.PublisherID = publisher.UID; item.Name = name; item.Detail = detail; item.Stock = stock; item.Volume = 0; item.Price = price; item.TimeCreate = DateTime.Now; item.Cut = cutType; item.Exist = true; Add(item); return item; }
public T_Shopping AddShopping(User user, Item item, int Count, string Cut = null) { T_Shopping tsh = GetT_Shopping(item, user); if (tsh == null) { tsh = new T_Shopping(); tsh.UID = user.UID; tsh.IID = item.IID; tsh.Count = Count; tsh.Cut = Cut; Add(tsh); } else { tsh.Count += Count; if (Cut != null) tsh.Cut = Cut; } return tsh; }
public T_Collection GetT_Collection(Item item, User user) { return yikuData.T_Collection.SingleOrDefault(tco => tco.IID == item.IID && tco.UID == user.UID ); }
public IQueryable<Order> OrderGetBySeller(User buyer) { return OrderGetBySeller(yikuData.Orders, buyer); }
public void DeleteShopping(User user, Item item) { T_Shopping tsh = GetT_Shopping(item, user); if (tsh != null) Delete(tsh); }
//T_Shopping Set public T_Shopping AddShopping(User user, Item item) { return AddShopping(user, item, 1, null); }
public bool UserExist(User user) { if(user != null) return user.Exist; return false; }
public IQueryable<Item> ItemGetShoppingItem(User buyer) { return from tsh in yikuData.T_Shopping where tsh.UID == buyer.UID orderby tsh.IID select tsh.Item; }
//publisher public IQueryable<Item> GetItems(User user) { return from i in yikuData.Items where i.PublisherID == user.UID select i; }
public T_Shopping GetT_Shopping(Item item, User user) { return yikuData.T_Shopping.SingleOrDefault(tsh => tsh.IID == item.IID && tsh.UID == user.UID ); }
public IQueryable<Item> ItemGetByBuyer(User buyer) { return ItemGetByBuyer(yikuData.Items, buyer); }
public IQueryable<T_Shopping> GetT_Shopping(User user) { return from tsh in yikuData.T_Shopping where tsh.UID == user.UID select tsh; }
public IQueryable<Order> GetOrders(User buyer) { return OrderGetByBuyer(buyer); }
/// <summary> /// 创建新的 User 对象。 /// </summary> /// <param name="uID">UID 属性的初始值。</param> /// <param name="name">Name 属性的初始值。</param> /// <param name="point">Point 属性的初始值。</param> /// <param name="exist">Exist 属性的初始值。</param> /// <param name="pSW">PSW 属性的初始值。</param> /// <param name="rOLE">ROLE 属性的初始值。</param> public static User CreateUser(global::System.Int32 uID, global::System.String name, global::System.Int64 point, global::System.Boolean exist, global::System.String pSW, global::System.String rOLE) { User user = new User(); user.UID = uID; user.Name = name; user.Point = point; user.Exist = exist; user.PSW = pSW; user.ROLE = rOLE; return user; }
public IQueryable<Order> OrderGetByBuyer(IQueryable<Order> orders, User buyer) { return from order in orders where order.UID == buyer.UID select order; }
/// <summary> /// 用于向 Users EntitySet 添加新对象的方法,已弃用。请考虑改用关联的 ObjectSet<T> 属性的 .Add 方法。 /// </summary> public void AddToUsers(User user) { base.AddObject("Users", user); }
public IQueryable<Order> OrderGetBySeller(IQueryable<Order> orders, User seller) { return from order in orders where order.Item.PublisherID == seller.UID select order; }
public IQueryable<Item> ItemGetBySeller(User seller) { return ItemGetBySeller(yikuData.Items, seller); }
public void DeleteCollection(User user, Item item) { T_Collection tco = GetT_Collection(item, user); if( tco != null) Delete(tco); }
public IQueryable<Item> ItemGetBySeller(IQueryable<Item> items, User seller) { return from i in items where i.PublisherID == seller.UID orderby i.IID select i; }
public IQueryable<T_Collection> GetT_Collections(User user) { return from tco in yikuData.T_Collection where tco.UID == user.UID select tco; }
public static bool UserIsCurrent(User user) { return UserCurrent.UID == user.UID; }