public async Task <IActionResult> DeleteNotePermantely(ListOfDeleteNotes deleteNotes) { try { var user = HttpContext.User; bool status = false; string message; if (user.HasClaim(c => c.Type == _tokenType)) { if (user.Claims.FirstOrDefault(c => c.Type == _tokenType).Value == _login && user.Claims.FirstOrDefault(c => c.Type == _userType).Value == _regularUser) { int UserId = Convert.ToInt32(user.Claims.FirstOrDefault(c => c.Type == _userId).Value); status = await _notesBusiness.DeleteNotePermantely(deleteNotes, UserId); if (status) { message = "Notes Deleted Successfully"; return(Ok(new { status, message })); } message = "No Such Notes Present to Delete. !!"; return(Ok(new { status, message })); } } message = "Invalid Token"; return(BadRequest(new { status, message })); } catch (Exception e) { return(BadRequest(new { e.Message })); } }
public async Task <bool> DeleteNotePermantely(ListOfDeleteNotes deleteNotes, int UserId) { try { if (deleteNotes == null || UserId <= 0) { return(false); } else { return(await _notesRepository.DeleteNotePermantely(deleteNotes, UserId)); } } catch (Exception e) { throw new Exception(e.Message); } }