示例#1
0
        /// <summary>
        /// 新增优惠券(后台)
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public ResultModel AddCouponType(ShowCouponTypeInfo model)
        {
            using (brnshopEntities context = new brnshopEntities())
            {
                var tran = context.Database.BeginTransaction();
                try
                {
                    //新增
                    if (model.ct_coupontypeid == 0)
                    {
                        bsp_coupontypes newcoupontype = new bsp_coupontypes();
                        newcoupontype.cutmoney         = model.ct_cutmoney;
                        newcoupontype.discount         = model.ct_discount;
                        newcoupontype.fullmoney        = model.ct_fullmoney;
                        newcoupontype.count            = 0;
                        newcoupontype.getmode          = 0;
                        newcoupontype.isstack          = model.ct_isstack;
                        newcoupontype.limitbrandid     = 0;
                        newcoupontype.limitcateid      = 0;
                        newcoupontype.limitproduct     = 0;
                        newcoupontype.money            = 0;
                        newcoupontype.name             = model.ct_name;
                        newcoupontype.orderamountlower = 0;
                        newcoupontype.sendendtime      = model.ct_sendendtime;
                        newcoupontype.sendmode         = 0;
                        newcoupontype.sendstarttime    = model.ct_sendstarttime;
                        newcoupontype.state            = 0;
                        newcoupontype.type             = model.ct_type;
                        newcoupontype.useendtime       = model.ct_useexpiretime == 1?model.ct_useendtime:DateTime.Now;
                        newcoupontype.useexpiretime    = model.ct_useexpiretime;
                        newcoupontype.usemode          = 0;
                        newcoupontype.userranklower    = 0;
                        newcoupontype.usestarttime     = model.ct_useexpiretime == 1 ? model.ct_usestarttime : DateTime.Now;
                        newcoupontype.isforgroup       = model.ct_isforgroup;
                        context.bsp_coupontypes.Add(newcoupontype);
                        context.SaveChanges();

                        if (model.ct_pid > 0)
                        {
                            bsp_couponproducts bsp_Couponproduct = new bsp_couponproducts();
                            bsp_Couponproduct.coupontypeid = newcoupontype.coupontypeid;
                            bsp_Couponproduct.pid          = model.ct_pid;
                            context.bsp_couponproducts.Add(bsp_Couponproduct);
                            context.SaveChanges();
                        }
                    }
                    tran.Commit();
                    return(ResultModel.Success("添加成功"));
                }
                catch (Exception ex)
                {
                    tran.Rollback();
                    Logger._.Error(ex);
                    return(ResultModel.Error());
                }
            }
        }
示例#2
0
 /// <summary>
 /// 新增优惠券(后台)
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public ResultModel AddCouponType(ShowCouponTypeInfo model)
 {
     throw new NotImplementedException();
 }
示例#3
0
        /// <summary>
        /// 新增优惠券(后台)
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public ActionResult AddCouponType(ShowCouponTypeInfo model)
        {
            COUPON coupon = RemotingHelp.GetModelObject <COUPON>();

            return(Json(coupon.AddCouponType(model), JsonRequestBehavior.AllowGet));
        }