Example #1
0
        public async Task <NoteResponse> IsTrash(IsTrashModel isTrash, int noteID, string userID)
        {
            try
            {
                //get all notes
                var note = this.authenticationContext.Note.Where(s => s.UserID == userID && s.NoteID == noteID).FirstOrDefault();
                //check whether data is null or not
                if (note != null)
                {
                    note.IsTrash      = isTrash.IsTrash;
                    note.ModifiedDate = DateTime.Now;
                    this.authenticationContext.Note.Update(note);
                    await this.authenticationContext.SaveChangesAsync();

                    NoteResponse data = this.GetNoteResponse(userID, note);
                    return(data);
                }
                else
                {
                    throw new Exception("Data Not found");
                }
            }
            catch (Exception e)
            {
                throw new Exception(e.Message);
            }
        }
Example #2
0
        public async Task <IActionResult> IsTrash(IsTrashModel isTrash, int noteID)
        {
            try
            {
                var userID = HttpContext.User.Claims.First(c => c.Type == "UserID").Value;
                var data   = await this.noteBL.IsTrash(isTrash, noteID, userID);

                bool success = false;
                var  message = string.Empty;
                if (data != null)
                {
                    success = true;
                    message = "Note is Updated";
                    return(this.Ok(new { success, message, data }));
                }
                else
                {
                    success = false;
                    message = "Note is not updated";
                    return(this.BadRequest(new { success, message }));
                }
            }
            catch (Exception e)
            {
                throw new Exception(e.Message);
            }
        }
Example #3
0
 public async Task <NoteResponse> IsTrash(IsTrashModel isTrash, int noteID, string userID)
 {
     try
     {
         if (userID != null)
         {
             return(await this.noteRL.IsTrash(isTrash, noteID, userID));
         }
         else
         {
             throw new Exception("User Not found");
         }
     }
     catch (Exception e)
     {
         throw new Exception(e.Message);
     }
 }