public static int CreateSocialCupon(int couponId) { try { using (couponEntities2 ce = new couponEntities2()) { Coupons_Social_Cupon couponsSocial = new Coupons_Social_Cupon(); couponsSocial.Id = couponId; ce.Coupons_Social_Cupon.Add(couponsSocial); ce.SaveChanges(); return(couponId); } } catch (Exception) { return(-1); } }
public static bool UpdateSocialCoupon(Coupons_Social_Cupon socialCupon) { try { using (couponEntities2 ce = new couponEntities2()) { var result = ce.Coupons_Social_Cupon.SingleOrDefault(b => b.Id == socialCupon.Id); if (result != null) { result.Coupon = socialCupon.Coupon; ce.SaveChanges(); } } } catch (Exception) { return(false); } return(true); }