public async Task <JsonResult> Reject([FromQuery] uint?id) { int projectId = this.ParseValue(id); int userId = int.Parse(User.Identity.Name); // Проверяем, что есть доступ var linkedProject = _dbContext.GetLinkedProjectForUser(projectId, userId); if (linkedProject == null) { throw new Exception(TextResource.API_YouAreNotInvited); } if (linkedProject.Accepted) { throw new Exception(TextResource.API_InviteAccepted); } _dbContext.Remove(linkedProject); await _dbContext.SaveChangesAsync() .ConfigureAwait(false); return(new JsonResult(new OkResponse { message = "Вы отказались от приглашения в проект" })); }