public JsonResult Edit(ActivityDiscount model) { try { var businessInfo = _businessInfoService.GetById(int.Parse(Loginer.BusinessId)); if (businessInfo == null) { return(Json(new { Status = Successed.Empty }, JsonRequestBehavior.AllowGet)); } if (model.ActivityDiscountId > 0) { var entity = _activityDiscountService.GetById(model.ActivityDiscountId); entity.Discount = model.Discount; entity.EditPersonId = Loginer.AccountId; entity.EditTime = DateTime.Now; //修改 _activityDiscountService.Update(entity); } else { //添加 //model.BusinessInfoId = int.Parse(Loginer.BusinessId); model.CreatePersonId = Loginer.AccountId; model.Status = (int)EnabledEnum.效; model.IsDelete = (int)IsDeleteEnum.效; model.CreateTime = DateTime.Now; model.EditPersonId = Loginer.AccountId; model.EditTime = DateTime.Now; model.ActivityDiscountId = 0; model = _activityDiscountService.Insert(model); businessInfo.ActivityDiscountId = model.ActivityDiscountId; _businessInfoService.Update(businessInfo); } } catch (Exception) { return(Json(new { Status = Successed.Error }, JsonRequestBehavior.AllowGet)); } return(Json(new { Status = Successed.Ok }, JsonRequestBehavior.AllowGet)); }
public JsonResult Edit(ActivityDiscount model, int businessInfoId) { var businessInfo = _businessInfo.GetById(businessInfoId); if (businessInfo == null) { return(Json(new { Status = Successed.Empty }, JsonRequestBehavior.AllowGet)); } //更新 if (model.ActivityDiscountId > 0) { var activityDiscount = _activityDiscountService.GetById(model.ActivityDiscountId); activityDiscount.EditPersonId = Loginer.AccountId; activityDiscount.EditTime = DateTime.Now; activityDiscount.Discount = model.Discount; try { _activityDiscountService.Update(activityDiscount); return(Json(new { Status = Successed.Ok }, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { return(Json(new { Status = Successed.Error }, JsonRequestBehavior.AllowGet)); } }//插入 else { //添加 model.CreatePersonId = Loginer.AccountId; model.EditPersonId = Loginer.AccountId; model.Status = (int)EnumHelp.EnabledEnum.效; model.IsDelete = (int)EnumHelp.IsDeleteEnum.效; model.CreateTime = DateTime.Now; model.EditTime = DateTime.Now; var activityDiscount = _activityDiscountService.Insert(model); businessInfo.ActivityDiscountId = activityDiscount.ActivityDiscountId; _businessInfo.Update(businessInfo); return(Json(new { Status = activityDiscount.ActivityDiscountId > 0?Successed.Ok:Successed.Error }, JsonRequestBehavior.AllowGet)); } }