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!" })); } }
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))); }
public async Task <IActionResult> Register(AuthorAddDto authorAddDto) { if (!ModelState.IsValid) { return(View(authorAddDto)); } await _authorService.AddAsync(authorAddDto); return(Redirect("/")); }
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)); }
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); }
public async Task <IActionResult> Add([FromBody] Author author) { await _authorService.AddAsync(author); return(CreatedAtAction(nameof(Get), new { id = author.Id }, author)); }
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)); }
public async Task <IActionResult> Post([FromBody] BLL.Models.Author author) { return(Ok(await service.AddAsync(author))); }