public async Task <EditMarkerResult> EditMarker(EditMarkerDto markerDto, string otp) { using var connection = GetConnection(); connection.Open(); using var transaction = connection.BeginTransaction(); var authResult = await authService.GetAuthResult(markerDto.Id, otp, transaction); if (authResult == AuthResult.Denied) { transaction.Commit(); return(EditMarkerResult.Unauthenticated); } connection.Execute(@" UPDATE [dbo].[Marker] SET [Name] = @name, [Description] = @description, [Location] = GEOGRAPHY::Point(@latitude, @longitude, 4326), [Type] = @type, [IsApproved] = @isApproved WHERE Id = @id", new { id = markerDto.Id, name = markerDto.Name, description = markerDto.Description, latitude = markerDto.Latitude, longitude = markerDto.Longitude, type = markerDto.Type.ToString(), isApproved = markerDto.IsApproved }, transaction); transaction.Commit(); return(EditMarkerResult.Succes); }
public async Task <ApprovalResultType> ApproveOrReject(bool approved, int markerId, string otp) { using var connection = GetConnection(); connection.Open(); using var transaction = connection.BeginTransaction(); var authResult = await authService.GetAuthResult(markerId, otp, transaction); if (authResult == AuthResult.Denied) { transaction.Commit(); return(ApprovalResultType.Unauthenticated); } connection.Execute(@" UPDATE [LaHistoricalMarkers].[dbo].[Marker] SET IsApproved = @approved WHERE [Id] = @markerId", new { approved, markerId }, transaction); transaction.Commit(); return(approved ? ApprovalResultType.Accepted : ApprovalResultType.Rejected); }