Ejemplo n.º 1
0
        private async Task AddNoteAsync()
        {
            var account = await _accountService.GetAsync(Session.Id);

            await _noteService.AddAsync(NoteForm, account);

            await ResetNoteFormAsync();
        }
Ejemplo n.º 2
0
        public async Task <ActionResult> Post([FromBody] NoteAdd value)
        {
            var result = await _noteService.AddAsync(value);

            if (result.IsError)
            {
                result.StatuCode = 400;
                return(BadRequest(result));
            }
            return(Ok(result));
        }
Ejemplo n.º 3
0
        public async Task <IActionResult> Index(CreateNoteCommand command)
        {
            try
            {
                await _noteService.AddAsync(command);

                return(RedirectToAction("List", "Home"));
            }
            catch (InternalSystemException ex)
            {
                return(View());
            }
        }
Ejemplo n.º 4
0
        public async Task <IActionResult> AddMessage(NoteAddDto messageAddDto)
        {
            var validationResult = await _noteAddDtoValidator.ValidateAsync(messageAddDto);

            if (!validationResult.IsValid)
            {
                return(BadRequest(new { errorMessage = "در اعتبارسنجی مشکلی پیش آمده است" }));
            }

            var token        = HttpContext.GetAuthenticationToken();
            var userJwtToken = await _jwtService.GetJwtTokenAsync(token);

            var messageGetDto = await _noteService.AddAsync(userJwtToken.UserId, messageAddDto);

            return(Ok(new { messageObj = messageGetDto, message = "پیام با موفقیت اضافه شد" }));
        }
Ejemplo n.º 5
0
        public async Task Create_Note_Success()
        {
            var userId = _context.Users.First().UserId;
            var note   = new NoteModel
            {
                Text = "Какой то текст"
            };

            //act
            var resultId = await _service.AddAsync(note, userId);

            var resultNote = await _context.Notes.SingleOrDefaultAsync(x => x.NoteId == resultId);

            //assert
            Assert.AreEqual(note.Text, resultNote.Text);
        }
Ejemplo n.º 6
0
        public async Task <IActionResult> AddNote(AddNoteViewModel model)
        {
            if (!this.ModelState.IsValid)
            {
                return(View(nameof(AddNote), model));
            }

            try
            {
                await _notesService.AddAsync(model.Note.EntityId, model.Note.NoteUser.Id, model.Note.Text, model.SelectedCategoryId, model.Note.HasStatus);

                return(RedirectToAction(nameof(Notes), new { entityId = model.Note.EntityId }));
            }
            catch (ArgumentException ex)
            {
                model.ErrorMessage = ex.Message;
                return(View(nameof(AddNote), model));
            }
        }
Ejemplo n.º 7
0
        public async Task <object> AddNote([FromBody] NoteModel mod, Guid idMaster)
        {
            var resultId = await _noteService.AddAsync(mod, idMaster);

            return(resultId);
        }