Ejemplo n.º 1
0
 /// <summary>
 /// 分享
 /// </summary>
 /// <param name="id"></param>
 /// <param name="code"></param>
 /// <returns></returns>
 public ActionResult AddShare(string id, TargetCode code)
 {
     if (code == TargetCode.Kanjia)
     {
         var kanjia = IKanJiaService.Find(id);
         if (kanjia == null || kanjia.IsDelete)
         {
             return(JResult(Core.Code.ErrorCode.sys_param_format_error, ""));
         }
         kanjia.ShareCount++;
         return(JResult(IKanJiaService.Update(kanjia)));
     }
     else if (code == TargetCode.Pintuan)
     {
         var pintuan = IPinTuanService.Find(id);
         if (pintuan == null || pintuan.IsDelete)
         {
             return(JResult(Core.Code.ErrorCode.sys_param_format_error, ""));
         }
         pintuan.ShareCount++;
         return(JResult(IPinTuanService.Update(pintuan)));
     }
     else if (code == TargetCode.Miaosha)
     {
         var miaosha = IMiaoShaService.Find(id);
         if (miaosha == null || miaosha.IsDelete)
         {
             return(JResult(Core.Code.ErrorCode.sys_param_format_error, ""));
         }
         miaosha.ShareCount++;
         return(JResult(IMiaoShaService.Update(miaosha)));
     }
     else if (code == TargetCode.Pintu)
     {
         var pintu = IPinTuService.Find(id);
         if (pintu == null || pintu.IsDelete)
         {
             return(JResult(Core.Code.ErrorCode.sys_param_format_error, ""));
         }
         pintu.ShareCount++;
         return(JResult(IPinTuService.Update(pintu)));
     }
     return(DataErorrJResult());
 }
Ejemplo n.º 2
0
        public JsonResult Manage(PinTu entity)
        {
            ModelState.Remove("CreatedTime");
            ModelState.Remove("UpdatedTime");
            ModelState.Remove("IsDelete");
            ModelState.Remove("IsNeedPay");
            ModelState.Remove("IsNeedReport");
            ModelState.Remove("UserID");
            if (ModelState.IsValid)
            {
                if (entity.ID.IsNullOrEmpty())
                {
                    if (entity.EndTime < entity.StartTime)
                    {
                        return(JResult(Core.Code.ErrorCode.end_time_error, ""));
                    }
                    if (entity.StartTime < DateTime.Now)
                    {
                        return(JResult(Core.Code.ErrorCode.start_time_error, ""));
                    }
                    entity.IsNeedPay    = true;
                    entity.IsNeedReport = false;
                    entity.UserID       = LoginUser.ID;
                    entity.CreatedTime  = entity.UpdatedTime = DateTime.Now;
                    var guid = Guid.NewGuid().ToString("N");
                    entity.ID = guid;
                    if (IPinTuService.Add(entity) > 0)
                    {
                        return(JResult(entity.ID.IsNullOrEmpty() ? guid : entity.ID));
                    }
                    else
                    {
                        return(DataErorrJResult());
                    }
                }
                else
                {
                    if (entity.EndTime < entity.StartTime)
                    {
                        return(JResult(Core.Code.ErrorCode.end_time_error, ""));
                    }
                    var model = IPinTuService.Find(entity.ID);
                    if (model == null || (model != null && model.IsDelete))
                    {
                        return(DataErorrJResult());
                    }
                    if (model.UserID != LoginUser.ID)
                    {
                        return(DataErorrJResult());
                    }

                    //if (IPinTuService.IsExits(x => x.Name == entity.Name && x.ID != entity.ID))
                    //{
                    //    return JResult(Core.Code.ErrorCode.system_name_already_exist, "");
                    //}
                    model.PhoneNumber           = entity.PhoneNumber;
                    model.Name                  = entity.Name;
                    model.Picture               = entity.Picture;
                    model.StartTime             = entity.StartTime;
                    model.EndTime               = entity.EndTime;
                    model.Amount                = entity.Amount;
                    model.Connact               = entity.Connact;
                    model.Rules                 = entity.Rules;
                    model.MusicUrl              = entity.MusicUrl;
                    model.FunctionName          = entity.FunctionName;
                    model.OldPrice              = entity.OldPrice;
                    model.LessPrice             = entity.LessPrice;
                    model.IntroduceTxtJson      = entity.IntroduceTxtJson;
                    model.PinTuItemJson         = entity.PinTuItemJson;
                    model.IntroducePicturesJson = entity.IntroducePicturesJson;
                    model.IntroduceVediosJson   = entity.IntroduceVediosJson;
                    model.Direction             = entity.Direction;
                    model.GoodsItemsJson        = entity.GoodsItemsJson;
                    model.PrizeCount            = entity.PrizeCount;
                    var result = IPinTuService.Update(model);
                    return(JResult(result));
                }
            }
            else
            {
                return(ParamsErrorJResult(ModelState));
            }
        }