/// <summary> /// /// </summary> /// <param name="id"></param> /// <returns></returns> public static PromotionPO GetDataForSave(int id) { PromotionPO item; if (id == 0) { item = new PromotionPO() { Name = "", Shortname = "", Description = "", ProductcategoryId = "", Effectdate = DateTime.Now, Expiredate = DateTime.Now, MerchantId = 0, Merchantundertake = 0, Platundertake = 0, Status = 0, Createtime = DateTime.Now, Updatetime = DateTime.Now, }; } else { item = GetItem(id); } return(item); }
/// <summary> /// /// </summary> /// <param name="id"></param> /// <returns></returns> public static bool Delete(int id) { var item = new PromotionPO { Id = id }; return(Delete(item)); }
/// <summary> /// /// </summary> /// <param name="item"></param> /// <returns></returns> public static bool Delete(PromotionPO item) { using (var context = new SchoolContext()) { context.Promotions.Attach(item); context.Promotions.Remove(item); context.SaveChanges(); } return(true); }
/// <summary> /// /// </summary> /// <param name="item"></param> /// <returns></returns> public static bool Save(PromotionPO item) { using (var context = new SchoolContext()) { if (item.Id == 0) { context.Promotions.Add(item); } else { context.Entry(item).State = EntityState.Modified; } context.SaveChanges(); } return(true); }
public static PromotionModel ToModel(this PromotionPO item) { if (item == null) { return(null); } return(new PromotionModel { Id = item.Id, Name = item.Name, Shortname = item.Shortname, Description = item.Description, ProductcategoryId = item.ProductcategoryId, Effectdate = item.Effectdate, Expiredate = item.Expiredate, MerchantId = item.MerchantId, Merchantundertake = item.Merchantundertake, Platundertake = item.Platundertake, Status = item.Status, Createtime = item.Createtime, Updatetime = item.Updatetime, }); }