本文整理汇总了C#中MicroEmall.Models.WMContext.SaveChanges方法的典型用法代码示例。如果您正苦于以下问题:C# WMContext.SaveChanges方法的具体用法?C# WMContext.SaveChanges怎么用?C# WMContext.SaveChanges使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MicroEmall.Models.WMContext
的用法示例。
在下文中一共展示了WMContext.SaveChanges方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddList
/// <summary>
/// 用购物车的数据填充订单商品表
/// </summary>
/// <param name="orderId">订单ID</param>
/// <param name="shopCars">购物车数据</param>
/// <returns>添加成功返回TRUE,否则返回FALSE</returns>
public static bool AddList(string orderId, List<WMShopCars> shopCars)
{
if (!General.IsNullable(orderId) && !General.IsNullable(shopCars))
{
WMOrderGoods model = null;
using (WMContext context = new WMContext())
{
foreach (WMShopCars item in shopCars)
{
model = new WMOrderGoods {
Id = General.UniqueString(),
OrderId = orderId,
GoodId = item.GoodId,
Price = item.Price,
Count = item.Count
};
context.OrderGoods.Add(model);
}
context.SaveChanges();
}
return true;
}
return false;
}
示例2: Delete
public static bool Delete(string id)
{
if (!General.IsNullable(id))
{
string fileName = null;
using (WMContext context = new WMContext())
{
GoodBrands model = context.GoodBrands.Find(id);
if (model != null)
{
if (!General.IsNullable(model.Logo))
fileName = "~" + model.Logo;
context.GoodBrands.Remove(model);
context.SaveChanges();
}
}
if (!General.IsNullable(fileName))
return Jumpcity.IO.FileHelper.DeleteFile(fileName);
return true;
}
return false;
}
示例3: Clear
public static bool Clear(string userId)
{
if (!General.IsNullable(userId))
{
using (WMContext context = new WMContext())
{
var list = (
from car in context.ShopCars
where car.UserId.Equals(userId)
select car
);
if (list != null)
{
foreach (var item in list)
context.ShopCars.Remove(item);
context.SaveChanges();
return true;
}
}
}
return false;
}
示例4: Delete
public static bool Delete(string userId)
{
if (!General.IsNullable(userId))
{
using (WMContext context = new WMContext())
{
Users model = context.Users.Find(userId);
if (model != null)
{
model.StatusId = 203;
context.SaveChanges();
return true;
}
}
}
return false;
}
示例5: Delete
public static bool Delete(int adminId)
{
if (adminId > 0)
{
using (WMContext context = new WMContext())
{
Administartors model = context.Administartors.Find(adminId);
if (model != null)
{
model.StatusId = 203;
context.SaveChanges();
return true;
}
}
}
return false;
}
示例6: Delete
public static bool Delete(string id)
{
if (!General.IsNullable(id))
{
using (WMContext context = new WMContext())
{
UserSets model = context.UserSets.Find(id);
if (model != null)
{
context.UserSets.Remove(model);
context.SaveChanges();
return true;
}
}
}
return false;
}
示例7: Delete
public static bool Delete(string id)
{
if (!General.IsNullable(id))
{
string fileName = null;
using (WMContext context =new WMContext())
{
GoodImages model = context.GoodImages.Find(id);
if (model != null)
{
fileName = "~" + model.URL;
GoodImages newCover = null;
if (model.IsCover)
{
newCover = (
from gi in context.GoodImages
where gi.GoodId.Equals(model.GoodId)
&& gi.Id != model.Id
orderby gi.AddDate descending
select gi
).FirstOrDefault();
if (newCover != null)
newCover.IsCover = true;
}
context.GoodImages.Remove(model);
context.SaveChanges();
}
}
return FileHelper.DeleteFile(fileName);
}
return false;
}
示例8: Add
public bool Add()
{
if (this.Valid())
{
this.Id = General.UniqueString(this.Id);
this.AddDate = DateTime.Now;
using (WMContext context = new WMContext())
{
Goods good = context.Goods.Find(this.GoodId);
if (good != null)
{
UserClicks model = (
from uc in context.UserClicks
where uc.PromoterId.Equals(this.PromoterId)
&& uc.CustomerId.Equals(this.CustomerId)
&& uc.GoodId.Equals(this.GoodId)
select uc
).FirstOrDefault();
if (model == null)
{
model = new UserClicks
{
Id = this.Id,
PromoterId = this.PromoterId,
CustomerId = this.CustomerId,
GoodId = this.GoodId,
AddDate = this.AddDate
};
good.Clicks++;
context.UserClicks.Add(model);
context.SaveChanges();
}
}
}
return true;
}
return false;
}
示例9: UpdateCover
public static bool UpdateCover(string id)
{
if (!General.IsNullable(id))
{
using (WMContext context = new WMContext())
{
GoodImages model = context.GoodImages.Find(id);
if (model != null)
{
GoodImages old = context.GoodImages.Where(gi => gi.GoodId.Equals(model.GoodId) && gi.IsCover).FirstOrDefault();
if (old != null)
old.IsCover = false;
model.IsCover = true;
context.SaveChanges();
return true;
}
}
}
return false;
}
示例10: Update
/// <summary>
/// 更新当前订单的速递单号、负责配送速递公司名称以及当前的订单状态
/// </summary>
/// <returns>更新成功返回True,否则返回False</returns>
public bool Update()
{
if (this.Valid(true))
{
using (WMContext context = new WMContext())
{
Orders model = context.Orders.Find(this.Id);
if (model != null)
{
model.ExpressId = this.ExpressId;
model.OddNumber = this.OddNumber;
model.StatusId = this.StatusId;
context.SaveChanges();
return true;
}
}
}
return false;
}
示例11: Add
public bool Add()
{
if (this.Valid())
{
this.Id = General.UniqueString(this.Id);
this.AddDate = DateTime.Now;
using (WMContext context = new WMContext())
{
UserBonus model = new UserBonus {
Id = this.Id,
UserId = this.UserId,
OrderId = this.OrderId,
BonusSum = this.BonusSum,
AddDate = this.AddDate
};
context.UserBonus.Add(model);
context.SaveChanges();
}
return true;
}
return false;
}
示例12: Update
public bool Update(bool updatePwd = false)
{
if (this.Valid(true))
{
using (WMContext context = new WMContext())
{
Users model = context.Users.Find(this.Id);
if (model != null)
{
model.UserName = this.UserName;
model.RoleId = this.RoleId;
model.NickName = this.NickName;
model.Integral = this.Integral;
model.Image = this.Image;
model.Mobile = this.Mobile;
model.BankCard = this.BankCard;
model.BankName = this.BankName;
model.StatusId = this.StatusId;
if (updatePwd)
model.Password = this.Password;
context.SaveChanges();
return true;
}
}
}
return false;
}
示例13: Update
public bool Update()
{
if (this.Valid(true))
{
using (WMContext context = new WMContext())
{
Goods model = context.Goods.Find(this.Id);
if (model != null)
{
model.CategoryId = this.CategoryId;
model.BrandId = this.BrandId;
model.Name = this.Name;
model.OriginalPrice = this.OriginalPrice;
model.PresentPrice = this.PresentPrice;
model.Unit = this.Unit;
model.Desc = this.Desc;
model.Spec = this.Spec;
model.Service = this.Service;
model.Integral = this.Integral;
model.Clicks = this.Clicks;
model.Saves = this.Saves;
model.Bonus = this.Bonus;
model.GoldPool = this.GoldPool;
model.StatusId = this.StatusId;
context.SaveChanges();
return true;
}
}
}
return false;
}
示例14: UpdateIntegral
public static bool UpdateIntegral(string userId, int addInte)
{
if (!General.IsNullable(userId))
{
using (WMContext context = new WMContext())
{
Users model = context.Users.Find(userId);
if (model != null)
{
model.Integral += addInte;
context.SaveChanges();
return true;
}
}
}
return false;
}
示例15: Payment
/// <summary>
/// 为指定的订单付款,并将相应的购买积分添加到用户的账户中
/// </summary>
/// <param name="orderId">要付款的订单ID</param>
/// <returns>付款成功返回TRUE,否则返回FALSE</returns>
public static bool Payment(string orderId)
{
bool flag = false;
if (!General.IsNullable(orderId))
{
string userId = null;
using (WMContext context = new WMContext())
{
Orders model = context.Orders.Find(orderId);
if (model != null)
{
userId = model.UserId;
model.Paid = true;
context.SaveChanges();
flag = true;
}
}
if (flag && !General.IsNullable(userId))
{
int inteSum = WMOrderGoods.GetIntegralSum(orderId);
return new WMUserIntegrals {
UserId = userId,
Integral = inteSum
}.Add();
}
}
return flag;
}