Пример #1
0
        public async Task <JsonResult> Add(string id)
        {
            if (id != null && id.Length > 5)
            {
                var result = await AuthorService.AddAsync(new Author()
                {
                    NameSurname = id.ToUpper()
                });

                if (result.isSuccess)
                {
                    return(Json(new BaseOperationModel()
                    {
                        isSuccess = true,
                        Message = "Yazar başarıyla eklendi!"
                    }));
                }
                else
                {
                    return(Json(new BaseOperationModel()
                    {
                        isSuccess = false,
                        Message = string.Join(";", result.Errors)
                    }));
                }
            }
            else
            {
                return(Json(new BaseOperationModel()
                {
                    isSuccess = false,
                    Message = "Girdiğiniz değerleri kontrol edin!"
                }));
            }
        }
Пример #2
0
        public async Task <ActionResult <AuthorDto> > Post([FromBody] AuthorCreateDto authorCreateDto)
        {
            AuthorDto newAuthor = _mapper.Map <AuthorDto>(
                await _authorService.AddAsync(_mapper.Map <Author>(authorCreateDto))
                );

            return(CreatedAtAction("Get", new { id = newAuthor.Id }, newAuthor));
        }
        public async Task <ActionResult> Post([FromBody] string author)
        {
            if (string.IsNullOrWhiteSpace(author))
            {
                return(this.BadRequest());
            }

            return(this.Created("", await authorService.AddAsync(author)));
        }
Пример #4
0
        public async Task <IActionResult> Register(AuthorAddDto authorAddDto)
        {
            if (!ModelState.IsValid)
            {
                return(View(authorAddDto));
            }

            await _authorService.AddAsync(authorAddDto);

            return(Redirect("/"));
        }
Пример #5
0
        public async Task <IHttpActionResult> Create([FromBody, CustomizeValidator] AuthorView author)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var authorInfo = _mapper.Map <AuthorView, AuthorInfo>(author);
            var result     = await _authorService.AddAsync(authorInfo);

            return(result.IsError ? BadRequest(result.Message) : (IHttpActionResult)Ok(result.Data));
        }
Пример #6
0
        public async Task <IActionResult> CreateAuthorAsync([FromBody] AuthorCreateDTO author)
        {
            if (author == null)
            {
                return(BadRequest(nameof(author)));
            }
            var  modelAuthor = _mapper.Map <Author>(author);
            bool flag        = await _authorService.AddAsync(modelAuthor);

            if (!flag)
            {
                return(StatusCode((int)HttpStatusCode.InternalServerError, "创建失败。"));
            }
            return(NoContent());
        }
 public async Task AddAsync(AuthorModel author)
 {
     await _authorService.AddAsync(author);
 }
Пример #8
0
        public async Task <IActionResult> Add([FromBody] Author author)
        {
            await _authorService.AddAsync(author);

            return(CreatedAtAction(nameof(Get), new { id = author.Id }, author));
        }
Пример #9
0
        public async Task <IActionResult> Add([FromBody] Author author)
        {
            await _authorService.AddAsync(author);

            return(Created("Author Added", null, author));
        }
        public async Task <IActionResult> AddAsync(AuthorInputModel authorInputModel)
        {
            var result = await service.AddAsync(authorInputModel);

            return(Ok(result));
        }
Пример #11
0
 public async Task <IActionResult> Post([FromBody] BLL.Models.Author author)
 {
     return(Ok(await service.AddAsync(author)));
 }