public int InsertBook(Dictionary <string, object> dic) { using (CommercedataContext context = new CommercedataContext()) { SupplierBookInfo info = JsonConvert.DeserializeObject <SupplierBookInfo>(dic["obj"].ToString()); string token = dic["token"].ToString(); if (token == "undefined") { return(0); } JWTHelper jWT = new JWTHelper(); UserRoderInfo user = JsonConvert.DeserializeObject <UserRoderInfo>(jWT.GetPayload(token)); var ue = context.UserRoderInfo.Where(n => n.ContactName.Equals(user.ContactName) && n.SupplierPwd.Equals(user.SupplierPwd)).FirstOrDefault(); if (ue == null) { return(0); } string SupplierId = ue.SuppLierId; var list = (from s in context.SupplierBookInfo where s.Isbn == info.Isbn select s).FirstOrDefault(); if (list == null) { info.Score = 0; info.SaledQuantity = 0; info.BookStues = "未出售"; info.SupplierId = SupplierId; context.SupplierBookInfo.Add(info); return(context.SaveChanges()); } else { return(0); } } }
public int AddOrder(OrderItems addOrder) { int count = 0; CommercedataContext context = new CommercedataContext(); OrderItems item = new OrderItems(); item.BookName = addOrder.BookName; item.BookPrice = addOrder.BookPrice; item.Isbn = addOrder.Isbn; item.OrderId = addOrder.OrderId; item.OrderitemId = addOrder.OrderitemId; item.Quantity = 1; item.Statue = "未支付"; item.SupplierId = addOrder.SupplierId; List <OrderItems> list = context.OrderItems.ToList(); list = list.Where(s => s.OrderitemId.Equals(addOrder.OrderitemId) && s.OrderId.Equals(addOrder.OrderId)).ToList(); if (list.Count != 0) { return(0); } context.OrderItems.Add(item); count = context.SaveChanges(); return(count); }
public int UpdBook(Dictionary <string, object> dic) { using (CommercedataContext context = new CommercedataContext()) { SupplierBookInfo info = JsonConvert.DeserializeObject <SupplierBookInfo>(dic["obj"].ToString()); string token = dic["token"].ToString(); if (token == "undefined") { return(0); } JWTHelper jWT = new JWTHelper(); UserRoderInfo user = JsonConvert.DeserializeObject <UserRoderInfo>(jWT.GetPayload(token)); var ue = context.UserRoderInfo.Where(n => n.ContactName.Equals(user.ContactName) && n.SupplierPwd.Equals(user.SupplierPwd)).FirstOrDefault(); if (ue == null) { return(0); } string SupplierId = ue.SuppLierId; var list = (from s in context.SupplierBookInfo where s.Isbn == info.Isbn select s).FirstOrDefault(); list.Price = info.Price; list.Discount = info.Discount; list.TotalQuantity = info.TotalQuantity; list.BookType = info.BookType; context.SupplierBookInfo.Update(list); return(context.SaveChanges()); } }
public int UpdUserRoder(Dictionary <string, object> dic) { using (CommercedataContext context = new CommercedataContext()) { UserRoderInfo info = JsonConvert.DeserializeObject <UserRoderInfo>(dic["obj"].ToString()); string token = dic["token"].ToString(); if (token == "undefined") { return(0); } JWTHelper jWT = new JWTHelper(); UserRoderInfo user = JsonConvert.DeserializeObject <UserRoderInfo>(jWT.GetPayload(token)); var ue = context.UserRoderInfo.Where(n => n.ContactName.Equals(user.ContactName) && n.SupplierPwd.Equals(user.SupplierPwd)).FirstOrDefault(); if (ue == null) { return(0); } string SupplierId = ue.SuppLierId; var list = (from s in context.UserRoderInfo where s.SuppLierId == SupplierId select s).FirstOrDefault(); list.ShopName = info.ShopName; list.ShopAddress = info.ShopAddress; list.ContactName = info.ContactName; list.CortactPhone = info.CortactPhone; list.Mail = info.Mail; list.TrueName = info.TrueName; context.UserRoderInfo.Update(list); //context.Set<UserRoderInfo>().Where(n=>n.SuppLierId.Equals(SupplierId)).Update(info); //context.Entry<UserRoderInfo>(info).State = EntityState.Modified; return(context.SaveChanges()); } }
public int DelBookData(string Isbn) { using (CommercedataContext context = new CommercedataContext()) { var list = (from s in context.SupplierBookInfo where s.Isbn == Isbn select s).FirstOrDefault(); context.SupplierBookInfo.Remove(list); return(context.SaveChanges()); } }
public int UpdaBookSate(string Isbn) { using (CommercedataContext context = new CommercedataContext()) { var list = (from s in context.SupplierBookInfo where s.Isbn == Isbn select s).FirstOrDefault(); list.BookStues = "出售中"; context.SupplierBookInfo.Update(list); return(context.SaveChanges()); } }
public int AddGuan(ManageInfo manageInfo) { int count = 0; CommercedataContext context = new CommercedataContext(); List <ManageInfo> list = context.ManageInfo.ToList(); list = list.Where(s => s.ManageId.Equals(manageInfo.ManageId)).ToList(); if (list.Count != 0) { return(0); } context.ManageInfo.Add(manageInfo); count = context.SaveChanges(); return(count); }
public int AddGong(UserRoderInfo userRoder) { int count = 0; CommercedataContext context = new CommercedataContext(); userRoder.RegDate = DateTime.Now; List <UserRoderInfo> list = context.UserRoderInfo.ToList(); list = list.Where(s => s.SuppLierId.Equals(userRoder.SuppLierId)).ToList(); if (list.Count != 0) { return(0); } context.UserRoderInfo.Add(userRoder); count = context.SaveChanges(); return(count); }
public int AddGu(Customer customer) { int count = 0; CommercedataContext context = new CommercedataContext(); customer.UserReddate = DateTime.Now; List <Customer> list = context.Customer.ToList(); list = list.Where(s => s.AccountId.Equals(customer.AccountId)).ToList(); if (list.Count != 0) { return(0); } context.Customer.Add(customer); count = context.SaveChanges(); return(count); }
public int UpdGoodFH(string token = "", string orderId = "") { using (CommercedataContext context = new CommercedataContext()) { if (token == "undefined") { return(0); } JWTHelper jWT = new JWTHelper(); UserRoderInfo user = JsonConvert.DeserializeObject <UserRoderInfo>(jWT.GetPayload(token)); var ue = context.UserRoderInfo.Where(n => n.ContactName.Equals(user.ContactName) && n.SupplierPwd.Equals(user.SupplierPwd)).FirstOrDefault(); if (ue == null) { return(0); } var list = context.UserorderRecound.Where(n => n.OrderId.Equals(orderId)).FirstOrDefault(); list.OrderStatue = "已发货"; context.UserorderRecound.Update(list); return(context.SaveChanges()); } }
public int UpdxBookSate(string token, string Isbn) { using (CommercedataContext context = new CommercedataContext()) { if (token == "undefined") { return(0); } JWTHelper jWT = new JWTHelper(); UserRoderInfo user = JsonConvert.DeserializeObject <UserRoderInfo>(jWT.GetPayload(token)); var ue = context.UserRoderInfo.Where(n => n.ContactName.Equals(user.ContactName) && n.SupplierPwd.Equals(user.SupplierPwd)).FirstOrDefault(); if (ue == null) { return(0); } string SupplierId = ue.SuppLierId; var list = (from s in context.SupplierBookInfo where s.Isbn == Isbn select s).FirstOrDefault(); list.BookStues = "未出售"; context.SupplierBookInfo.Update(list); return(context.SaveChanges()); } }
//添加数据 public int Add(T t) { db.Set <T>().Add(t); return(db.SaveChanges()); }