Example #1
0
        public async Task <IActionResult> CreateNewNoteAccess(string id, string token, [FromBody] Object inputValue)
        {
            try
            {
                var userEmail = JObject.Parse(inputValue.ToString()).Value <String>("UserEmail");
                var user      = await new UserService().GetUserByEmail(userEmail);

                var sharedNoteModel = new SharedNote()
                {
                    UserId = user.Id,
                    NoteId = id,
                    Role   = JObject.Parse(inputValue.ToString()).Value <String>("Role")
                };

                await _sharedNoteService.Create(sharedNoteModel);

                return(Ok());
            }
            catch
            {
                var senderEmai   = _tokenManagerService.User.Email;
                var setterEmail  = JObject.Parse(inputValue.ToString()).Value <String>("UserEmail");
                var emailService = new EmailService();
                var result       = await emailService.ShareItemMessageBuild(senderEmai, setterEmail, id);

                return(Ok(result));
            }
        }
Example #2
0
        public bool NoteShare(Note note, int UserID)
        {
            SharedNote sharedNote = new SharedNote();

            sharedNote.NoteID = note.ID;
            sharedNote.UserID = UserID;
            db.SharedNoteRepository.Add(sharedNote);
            return(db.ApplyChanges());
        }
Example #3
0
        public async Task <IActionResult> CreateShared([Bind("Id,UserUniqueName")] SharedNote sharedNote, int SharedNoteId)
        {
            Note note = _context.Note.Single(x => x.id == SharedNoteId);

            sharedNote.TimeNoteSent         = DateTime.Now;
            sharedNote.Title                = note.Title;
            sharedNote.NoteContent          = note.NoteContent;
            sharedNote.SenderUserUniqueName = note.UserUniqueName;
            sharedNote.UserName             = note.UserName;



            if (ModelState.IsValid)
            {
                _context.Add(sharedNote);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(sharedNote));
        }