public async Task <IActionResult> DislikeProfile([FromQuery][Required] long userId) { if (userId == MyId) { throw new MatchaException(HttpStatusCode.Forbidden, "Нельзя поставить дизлайк самому себе"); } using var connection = new MySqlConnection(AppConfig.Constants.DbConnectionString); using var command = new MySqlCommand("DislikeProfile", connection) { CommandType = CommandType.StoredProcedure }; command.Parameters.AddRange(new[] { new MySqlParameter("who", MyId), new MySqlParameter("whom", userId), new MySqlParameter("disliked_yet", MySqlDbType.Bit) { Direction = ParameterDirection.ReturnValue } }); connection.Open(); await command.ExecuteNonQueryAsync(); var disliked = Convert.ToBoolean(command.Parameters["disliked_yet"].Value); if (disliked is false) { await WebSocketsManager.WebSocketsManager.Send( userId, new WebSocketResponseModel { Type = WebSocketRequestType.Notification.ToString(), Sender = WebSocketsController.GetProfileShortInfo(MyId), Notification = new WebSocketResponseNotification { Type = WebSocketNotificationType.Dislike.ToString(), Actioner = MyId } } ); } return(ResponseModel.OK.ToResult()); }
public async Task <IActionResult> VisitProfile([FromQuery][Required] long userId) { if (userId == MyId) { return(ResponseModel.OK.ToResult()); } using var connection = new MySqlConnection(AppConfig.Constants.DbConnectionString); using var command = new MySqlCommand("VisitProfile", connection) { CommandType = CommandType.StoredProcedure }; command.Parameters.AddRange(new[] { new MySqlParameter("who", MyId), new MySqlParameter("whom", userId) }); connection.Open(); await command.ExecuteNonQueryAsync(); await WebSocketsManager.WebSocketsManager.Send( userId, new WebSocketResponseModel { Type = WebSocketRequestType.Notification.ToString(), Sender = WebSocketsController.GetProfileShortInfo(MyId), Notification = new WebSocketResponseNotification { Type = WebSocketNotificationType.Visit.ToString(), Actioner = MyId } } ); return(ResponseModel.OK.ToResult()); }