Beispiel #1
0
        public IActionResult DeleteNote(long noteId)
        {
            try
            {
                if (User.Identity is ClaimsIdentity identity)
                {
                    IEnumerable <Claim> claims = identity.Claims;
                    long   UserID = Convert.ToInt64(claims.Where(p => p.Type == "UserId").FirstOrDefault()?.Value);
                    string Email  = claims.Where(p => p.Type == "Email").FirstOrDefault()?.Value;

                    ResponseNoteModel result = notesBL.DeleteNote(UserID, noteId).Result;
                    if (result == null)
                    {
                        return(Ok(new { success = true, user = Email, Message = "Note deleted sucessfully", Note = result }));
                    }
                    else
                    {
                        return(Ok(new { success = true, user = Email, Message = "Note is added to trash", Note = result }));
                    }
                }
                return(BadRequest(new { success = false, Message = "no user is active please login" }));
            }
            catch (Exception exception)
            {
                return(BadRequest(new { success = false, exception.Message }));
            }
        }
Beispiel #2
0
        public async Task <IActionResult> DeleteNote(int Id)
        {
            var userId = TokenUserId();

            if (await note.DeleteNote(Id, userId))
            {
                string status = "Note deleted";
                return(Ok(new { status, userId, Id }));
            }
            else
            {
                string status = "Note is not deleted";
                return(BadRequest(new { status, userId, Id }));
            }
        }
 public IActionResult DeleteNote(long NoteId)
 {
     try
     {
         var identity = User.Identity as ClaimsIdentity;
         if (identity != null)
         {
             IEnumerable <Claim> claims = identity.Claims;
             long   Id           = Convert.ToInt64(claims.Where(p => p.Type == "Id").FirstOrDefault()?.Value);
             string EmailAddress = claims.Where(p => p.Type == "EmailAddress").FirstOrDefault()?.Value;
             bool   result       = noteBL.DeleteNote(Id, NoteId).Result;
             return(Ok(new { success = true, user = EmailAddress, Message = "note deleted" }));
         }
         return(BadRequest(new { success = false, Message = "no user is active please login" }));
     }
     catch (Exception exception)
     {
         return(BadRequest(new { success = false, exception.Message }));
     }
 }