/// <summary> /// 编辑车友群 /// </summary> /// <param name="model"></param> /// <returns></returns> public bool UpdateCarFriendsGroup(CarFriendsGroupModel model) { bool result = false; try { using (var conn = ProcessConnection.OpenGungnir) { result = dal.UpdateCarFriendsGroup(conn, model); } } catch (Exception e) { Logger.Error($"UpdateCarFriendsGroup -> {JsonConvert.SerializeObject(model)}", e); throw; } return(result); }
/// <summary> /// 编辑车友群 /// </summary> /// <param name="model"></param> /// <returns></returns> public ActionResult UpdateCarFriendsGroup(CarFriendsGroupModel model) { var manager = new CarFriendsGroupManager(); model.GroupCreateTime = DateTime.Now; model.GroupOverdueTime = model.GroupCreateTime.AddDays(7); model.CreateBy = User.Identity.Name; model.LastUpdateBy = User.Identity.Name; bool isSuccess = manager.UpdateCarFriendsGroup(model); if (isSuccess) { return(Json(new { status = isSuccess, msg = "编辑成功!" })); } else { return(Json(new { status = isSuccess, msg = "编辑失败!" })); } }
/// <summary> /// 编辑车友群 /// </summary> /// <param name="conn"></param> /// <param name="model"></param> /// <returns></returns> public bool UpdateCarFriendsGroup(SqlConnection conn, CarFriendsGroupModel model) { string sql = @" UPDATE Activity.[dbo].[CarFriendsWeChatGroup] WITH ( ROWLOCK ) SET [GroupName] = @GroupName , [GroupDesc] = @GroupDesc , [BindBrand] = @BindBrand , [BindVehicleType] = @BindVehicleType , [BindVehicleTypeID] = @BindVehicleTypeID , [GroupHeadPortrait] = @GroupHeadPortrait , [GroupQRCode] = @GroupQRCode , [GroupCategory] = @GroupCategory , [GroupWeight] = @GroupWeight , [IsRecommend] = @IsRecommend , [GroupCreateTime] = @GroupCreateTime , [GroupOverdueTime] = @GroupOverdueTime , [LastUpdateDateTime] = GETDATE() , [LastUpdateBy] = @LastUpdateBy WHERE PKID = @PKID;"; var parameters = new[] { new SqlParameter("@GroupName", model.GroupName ?? ""), new SqlParameter("@GroupDesc", model.GroupDesc ?? ""), new SqlParameter("@BindBrand", model.BindBrand), new SqlParameter("@BindVehicleType", model.BindVehicleType), new SqlParameter("@BindVehicleTypeID", model.BindVehicleTypeID), new SqlParameter("@GroupHeadPortrait", model.GroupHeadPortrait ?? ""), new SqlParameter("@GroupQRCode", model.GroupQRCode ?? ""), new SqlParameter("@GroupCategory", model.GroupCategory), new SqlParameter("@GroupWeight", model.GroupWeight), new SqlParameter("@IsRecommend", model.IsRecommend), new SqlParameter("@GroupCreateTime", model.GroupCreateTime), new SqlParameter("@GroupOverdueTime", model.GroupOverdueTime), new SqlParameter("@LastUpdateBy", model.LastUpdateBy ?? ""), new SqlParameter("@PKID", model.PKID) }; return(SqlHelper.ExecuteNonQuery(conn, CommandType.Text, sql, parameters) > 0); }
/// <summary> /// 新建车友群 /// </summary> /// <param name="conn"></param> /// <param name="model"></param> /// <returns></returns> public bool AddCarFriendsGroup(SqlConnection conn, CarFriendsGroupModel model) { string sql = @" INSERT INTO Activity.[dbo].[CarFriendsWeChatGroup] ( [GroupName] , [GroupDesc] , [BindBrand] , [BindVehicleType] , [BindVehicleTypeID] , [GroupHeadPortrait] , [GroupQRCode] , [GroupCategory] , [GroupWeight] , [IsRecommend] , [Is_Deleted] , [GroupCreateTime] , [GroupOverdueTime] , [CreateDatetime] , [LastUpdateDateTime] , [CreateBy] , [LastUpdateBy] ) VALUES ( @GroupName , @GroupDesc , @BindBrand , @BindVehicleType , @BindVehicleTypeID , @GroupHeadPortrait , @GroupQRCode , @GroupCategory , @GroupWeight , @IsRecommend , @Is_Deleted , @GroupCreateTime , @GroupOverdueTime , GETDATE() , GETDATE() , @CreateBy , @LastUpdateBy ); SELECT SCOPE_IDENTITY();"; var parameters = new[] { new SqlParameter("@GroupName", model.GroupName ?? ""), new SqlParameter("@GroupDesc", model.GroupDesc ?? ""), new SqlParameter("@BindBrand", model.BindBrand), new SqlParameter("@BindVehicleType", model.BindVehicleType), new SqlParameter("@BindVehicleTypeID", model.BindVehicleTypeID), new SqlParameter("@GroupHeadPortrait", model.GroupHeadPortrait ?? ""), new SqlParameter("@GroupQRCode", model.GroupQRCode ?? ""), new SqlParameter("@GroupCategory", model.GroupCategory), new SqlParameter("@GroupWeight", model.GroupWeight), new SqlParameter("@IsRecommend", model.IsRecommend), new SqlParameter("@Is_Deleted", model.Is_Deleted), new SqlParameter("@GroupCreateTime", model.GroupCreateTime), new SqlParameter("@GroupOverdueTime", model.GroupOverdueTime), new SqlParameter("@CreateBy", model.CreateBy ?? ""), new SqlParameter("@LastUpdateBy", model.LastUpdateBy ?? "") }; return(Convert.ToInt32(SqlHelper.ExecuteScalar(conn, CommandType.Text, sql, parameters)) > 0); }