예제 #1
0
        public async Task <NoteResponse> IsArchieve(IsArchieveModel isArchieve, int noteID, string userID)
        {
            try
            {
                //get all the notes
                var note = this.authenticationContext.Note.Where(s => s.UserID == userID && s.NoteID == noteID).FirstOrDefault();
                //check whether the data is null ornot
                if (note != null)
                {
                    note.IsArchive    = isArchieve.IsArchieve;
                    note.ModifiedDate = DateTime.Now;
                    this.authenticationContext.Note.Update(note);
                    await this.authenticationContext.SaveChangesAsync();

                    NoteResponse data = this.GetNoteResponse(userID, note);
                    return(data);
                }
                //data not found
                else
                {
                    throw new Exception("data not found");
                }
            }
            catch (Exception e)
            {
                throw new Exception(e.Message);
            }
        }
예제 #2
0
        public async Task <IActionResult> IsArchieve(IsArchieveModel isArchieve, int noteID)
        {
            try
            {
                var userID = HttpContext.User.Claims.First(c => c.Type == "UserID").Value;
                var data   = await this.noteBL.IsArchieve(isArchieve, 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);
            }
        }
예제 #3
0
 public async Task <NoteResponse> IsArchieve(IsArchieveModel isArchieve, int noteID, string userID)
 {
     try
     {
         //check whether the userId is not null
         if (userID != null)
         {
             //if usrerid is not null then pass that id to Respository layer method to display notes of that user
             return(await this.noteRL.IsArchieve(isArchieve, noteID, userID));
         }
         else
         {
             //if user id contains null value then throw exception
             throw new Exception("User Not found");
         }
     }
     catch (Exception e)
     {
         throw new Exception(e.Message);
     }
 }