/// <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()); }
/// <summary> /// 增加 /// </summary> /// <returns></returns> public ActionResult Update(WST.Model.PinTuan entity) { ModelState.Remove("UpdatedTime"); ModelState.Remove("CreatedTime"); if (ModelState.IsValid) { var model = IPinTuanService.Find(entity.ID); if (model == null || (model != null && model.IsDelete)) { return(DataErorrJResult()); } if (IPinTuanService.IsExits(x => x.Name == entity.Name && x.ID != entity.ID)) { return(JResult(Core.Code.ErrorCode.system_name_already_exist, "")); } model.Name = entity.Name; model.Picture = entity.Picture; model.StartTime = entity.StartTime; model.EndTime = entity.EndTime; model.Amount = entity.Amount; model.IsNeedPay = entity.IsNeedPay; model.IsNeedReport = entity.IsNeedReport; model.Connact = entity.Connact; model.Rules = entity.Rules; model.MusicUrl = entity.MusicUrl; model.FunctionName = entity.FunctionName; var result = IPinTuanService.Update(model); return(JResult(result)); } else { return(ParamsErrorJResult(ModelState)); } }
public JsonResult Manage(PinTuan 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 (IPinTuanService.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 = IPinTuanService.Find(entity.ID); if (model == null || (model != null && model.IsDelete)) { return(DataErorrJResult()); } if (model.UserID != LoginUser.ID) { return(DataErorrJResult()); } //if (IPinTuanService.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.IntroduceTxtJson = entity.IntroduceTxtJson; model.IntroducePicturesJson = entity.IntroducePicturesJson; model.IntroduceVediosJson = entity.IntroduceVediosJson; model.Direction = entity.Direction; model.GoodsItemsJson = entity.GoodsItemsJson; model.PinTuanItemJson = entity.PinTuanItemJson; model.PrizeCount = entity.PrizeCount; var result = IPinTuanService.Update(model); return(JResult(result)); } } else { return(ParamsErrorJResult(ModelState)); } }