public async Task <bool> IsTrash(int userId, int noteId, TrashArchivePin trash) { if (userId != 0 && noteId != 0) { return(await _notesRepository.IsTrash(userId, noteId, trash)); } else { return(false); } }
public async Task <IActionResult> IsTrash(int noteId, TrashArchivePin trash) { try { var user = HttpContext.User; bool status; string message; if (user.HasClaim(c => c.Type == "TokenType")) { if (user.Claims.FirstOrDefault(c => c.Type == "TokenType").Value == "Login") { int userId = Convert.ToInt32(user.Claims.FirstOrDefault(c => c.Type == "Id").Value); bool result = await this._notesBusiness.IsTrash(userId, noteId, trash); if (result == true && trash.value == true) { status = true; message = "note moved to trash"; return(this.Ok(new { status, message })); } if (result == true && trash.value == false) { status = true; message = "note moved from trash"; return(this.Ok(new { status, message })); } if (!result) { status = false; message = "note not found "; return(this.NotFound(new { status, message })); } } } status = false; message = "Note not available"; return(this.NotFound(new { status, message })); } catch (Exception e) { return(this.BadRequest(new { e.Message })); } }
public async Task <IActionResult> IsPin(int noteId, [FromBody] TrashArchivePin pin) { try { var user = HttpContext.User; bool status; string message; if (user.HasClaim(c => c.Type == "TokenType")) { if (user.Claims.FirstOrDefault(c => c.Type == "TokenType").Value == "Login") { int userId = Convert.ToInt32(user.Claims.FirstOrDefault(c => c.Type == "Id").Value); bool data = await this._notesBusiness.IsPin(userId, noteId, pin); if (data == true && pin.value == true) { status = true; message = "note pinned"; return(this.Ok(new { status, message })); } if (data == true && pin.value == false) { status = true; message = "note unpinned"; return(this.Ok(new { status, message })); } if (!data) { status = false; message = "note not found "; return(this.NotFound(new { status, message })); } } } status = false; message = "Note not available"; return(this.NotFound(new { status, message })); } catch (Exception e) { return(this.BadRequest(new { e.Message })); } }