protected override BaseResponse <EmptyViewModel> ExecuteCore(GenericRequestViewModel <int> request) { var assignment = repository .Assignments .ReadNotDeleted(x => x.Id == request.Data) .Include(x => x.Epic) .ThenInclude(x => x.Project) .SingleOrDefault(); if (assignment is null) { return(GetGenericResponseFailed()); } var validationResult = ValidateProjectAccess(projectService, assignment.Epic.Project.Id); if (!validationResult.Response.Success) { return(validationResult.Response); } repository.Delete(assignment, CurrentApplicationUser); repository.SaveChanges(); return(GetResponseSuccess(message: Resources.AssignmentDeletedSuccessfully)); }
protected override BaseResponse <EmptyViewModel> ExecuteCore(GenericRequestViewModel <int> request) { var project = repository .Projects .ReadNotDeleted(x => x.Id == request.Data) .SingleOrDefault(); if (project is null) { return(GetGenericResponseFailed()); } var validationResult = ValidateProjectAccess(projectService, project.Id); if (!validationResult.Response.Success) { return(validationResult.Response); } if (project.CreatedBy != CurrentApplicationUser) { return(GetGenericResponseFailed()); } repository.Delete(project, CurrentApplicationUser); repository.SaveChanges(); return(GetResponseSuccess(message: Resources.ProjectDeletedSuccessfully)); }
protected override BaseResponse <IList <NotificationDto> > ExecuteCore(GenericRequestViewModel <int> request) { var notifications = repository.Notifications .Read(x => x.User == CurrentApplicationUser && x.Project.Id == request.Data) .Include(x => x.Project) .ToList(); var notificationDtos = notifications.Select(x => new NotificationDto { Id = x.Id, Content = x.Content, IsRead = x.IsRead, CreatedOn = x.CreatedOn, Type = x.Type }) .OrderBy(x => x.IsRead) .ThenByDescending(x => x.CreatedOn) .ToList(); notifications.ForEach(x => x.IsRead = true); repository.SaveChanges(); return(GetGenericResponseSuccess(notificationDtos)); }
protected override BaseResponse <EmptyViewModel> ExecuteCore(GenericRequestViewModel <int> request) { var comment = repository.Comments .ReadNotDeleted(x => x.Id == request.Data) .Include(x => x.CreatedBy) .SingleOrDefault(); if (comment == null || comment.CreatedBy != CurrentApplicationUser) { return(GetGenericResponseFailed()); } repository.Delete(comment, CurrentApplicationUser); repository.SaveChanges(); return(GetGenericResponseSuccess(null)); }
protected override BaseResponse <EmptyViewModel> ExecuteCore(GenericRequestViewModel <int> request) { var discussionMessage = repository.DiscussionMessages .Read(x => x.Id == request.Data) .Include(x => x.CreatedBy) .Include(x => x.Project) .SingleOrDefault(); if (discussionMessage?.CreatedBy != CurrentApplicationUser) { return(GetGenericResponseFailed()); } discussionHub.Clients.Group(discussionMessage.Project.Id.ToString()) .SendAsync("MessageRemoved", discussionMessage.Id.ToString()); repository.Delete(discussionMessage, CurrentApplicationUser); repository.SaveChanges(); return(GetGenericResponseSuccess(null)); }
protected override BaseResponse <EmptyViewModel> ExecuteCore(GenericRequestViewModel <int> request) { var invitation = repository .Invitations .Read(x => x.Id == request.Data) .Include(x => x.Project) .ThenInclude(x => x.Collaborators) .FirstOrDefault(); var validationResult = ValidateProjectAccess(projectService, invitation.Project.Id); if (!validationResult.Response.Success) { return(validationResult.Response); } repository.Delete(invitation, CurrentApplicationUser); repository.SaveChanges(); return(GetResponseSuccess(message: Resources.Invitation_Canceled)); }