public static async Task <IActionResult> RunGeoHash( [HttpTrigger(AuthorizationLevel.Function, "delete", Route = "interventions/{latitude}/{longitude}/{interventionId}/comments/{commentId}")] [RequestBodyType(typeof(DeletionRequest), "DeletionRequest")] DeletionRequest request, [Table(Config.InterventionsTableName, Connection = Config.StorageConnectionName)] CloudTable interventionsTable, string latitude, string longitude, string interventionId, string commentId, ILogger log) { var geoHash = GeoHasher.GetGeoHash(latitude, longitude); var finalFilter = InterventionFilterBuilder.GetInterventionGeoHashFilter(geoHash, interventionId); var queryResult = await interventionsTable.ExecuteQuerySegmentedAsync(new TableQuery <InterventionEntity>().Where( finalFilter).Take(1), null); var requestedIntervention = queryResult.Results.FirstOrDefault(); if (requestedIntervention == null) { return(new StatusCodeResult(StatusCodes.Status404NotFound)); } try { requestedIntervention.DeleteComment(commentId); await interventionsTable.ExecuteAsync(TableOperation.Merge(requestedIntervention)); } catch (InvalidOperationException e) { return(new StatusCodeResult(StatusCodes.Status404NotFound)); } return(new StatusCodeResult(StatusCodes.Status200OK)); }
public static async Task <IActionResult> Run( [HttpTrigger(AuthorizationLevel.Function, "delete", Route = "interventions/{interventionId}/comments/{commentId}")] [RequestBodyType(typeof(DeletionRequest), "DeletionRequest")] DeletionRequest request, [Table(Config.InterventionsTableName, Connection = Config.StorageConnectionName)] CloudTable interventionsTable, string interventionId, string commentId, ILogger log) { var queryResult = await interventionsTable.ExecuteQuerySegmentedAsync(new TableQuery <InterventionEntity>().Where( TableQuery.GenerateFilterCondition("RowKey", QueryComparisons.Equal, interventionId)).Take(1), null); var requestedIntervention = queryResult.Results.FirstOrDefault(); if (requestedIntervention == null) { return(new StatusCodeResult(StatusCodes.Status404NotFound)); } try { requestedIntervention.DeleteComment(commentId); await interventionsTable.ExecuteAsync(TableOperation.Merge(requestedIntervention)); } catch (InvalidOperationException e) { return(new StatusCodeResult(StatusCodes.Status404NotFound)); } return(new StatusCodeResult(StatusCodes.Status200OK)); }
public ActionResult DeleteFeedRequest(int id) { var request = new DeletionRequest { FeedId = id, UserId = User.Identity.GetUserId(), ReasonForDeletion = Request.Params["reason"], RequestClosed = false, AdminResponse = "" }; var deletionRequest = new DeletionRequests(_deletionRequestRepository, _unitOfWork); var isCreated = deletionRequest.TryCreateRequest(request); if (isCreated) { var userNotification = CreateUserNotification(request); var notification = new BLLUserNotificationTypes(userNotification, _unitOfWork); notification.CreateUserNotification(); var redirectUrl = new UrlHelper(Request.RequestContext).Action("Details", "Feed", new { id }); return(Json(new { Url = redirectUrl })); } return(HttpNotFound()); }
public bool TryCreateRequest(DeletionRequest deletionRequest) { if (deletionRequest != null) { CreateRequest(deletionRequest); return(true); } return(false); }
internal DeletionRequest UpdateDeletionRequest(DeletionRequest request) { request.DeletionDate = this.DeletionDate; request.MemberName = this.MemberName; request.MemberShipNo = this.MemberShipNo; request.Nationality = this.Nationality; request.Status = this.Status; request.Reason = this.Reason; return(request); }
public DeletionRequestDto FromDeletionRequest(DeletionRequest req) { return(new DeletionRequestDto { ID = req.ID, CreatedAt = req.CreatedAt, DeletionDate = req.DeletionDate, MemberName = req.MemberName, MemberShipNo = req.MemberShipNo, Nationality = req.Nationality, Status = req.Status }); }
public void Delete() { TwitterAccount info; if (this.IsDirectMessage) { var ids = new[] { this.Status.User.Id, this.Status.Recipient.Id }; info = ids .Select(Setting.Accounts.Get).FirstOrDefault(_ => _ != null); } else { info = Setting.Accounts.Get(this.OriginalStatus.User.Id); } if (info == null) { return; } var dreq = new DeletionRequest(this.OriginalStatus); RequestQueue.Enqueue(info, dreq) .Subscribe(_ => StatusInbox.EnqueueRemoval(_.Id), ex => BackstageModel.RegisterEvent(new OperationFailedEvent("ツイートを削除できませんでした", ex))); }
public void Delete() { TwitterAccount info; if (this.IsDirectMessage) { var ids = new[] { this.Status.User.Id, this.Status.Recipient.Id }; info = ids .Select(Setting.Accounts.Get).FirstOrDefault(_ => _ != null); } else { info = Setting.Accounts.Get(this.OriginalStatus.User.Id); } if (info == null) return; var dreq = new DeletionRequest(this.OriginalStatus); RequestQueue.Enqueue(info, dreq) .Subscribe(_ => StatusInbox.QueueRemoval(_.Id), ex => BackstageModel.RegisterEvent( new OperationFailedEvent("ツイートを削除できませんでした: " + ex.Message))); }
private void CreateRequest(DeletionRequest deletionRequest) { _unitOfWork.DeletionRequests.Add(deletionRequest); _unitOfWork.Complete(); }
public void Delete() { TwitterAccount info; if (this.IsDirectMessage) { var ids = this.Status.Recipient == null ? new[] { this.Status.User.Id } : new[] { this.Status.User.Id, this.Status.Recipient.Id }; info = ids .Select(Setting.Accounts.Get).FirstOrDefault(_ => _ != null); } else { info = Setting.Accounts.Get(this.OriginalStatus.User.Id); } if (info == null) return; var dreq = new DeletionRequest(this.OriginalStatus); RequestQueue.Enqueue(info, dreq) .Subscribe(_ => StatusInbox.EnqueueRemoval(_.Id), ex => BackstageModel.RegisterEvent( new OperationFailedEvent(MainAreaTimelineResources.MsgTweetDeleteFailed, ex))); }
private IUserNotification CreateUserNotification(DeletionRequest deletionRequest) { return(Mapper.Map <DeletionResponseNotificationDto>(deletionRequest)); }
public void Delete() { TwitterAccount info; if (IsDirectMessage) { var ids = Status.Recipient == null ? new[] { Status.User.Id } : new[] { Status.User.Id, Status.Recipient.Id }; info = ids .Select(Setting.Accounts.Get).FirstOrDefault(_ => _ != null); } else { info = Setting.Accounts.Get(OriginalStatus.User.Id); } if (info == null) return; Task.Run(async () => { var dreq = new DeletionRequest(OriginalStatus); try { var result = await RequestQueue.EnqueueAsync(info, dreq).ConfigureAwait(false); StatusInbox.EnqueueRemoval(result.Id); } catch (Exception ex) { BackstageModel.RegisterEvent(new OperationFailedEvent( MainAreaTimelineResources.MsgTweetDeleteFailed, ex)); } }); }
private IUserNotification CreateUserNotification(DeletionRequest request) { return(Mapper.Map <DeletionRequestNotificationDto>(request)); }