public async Task <Result> Create(NewGenreDto data) { var result = new Result(); if (string.IsNullOrWhiteSpace(data.Name)) { result.IsSuccess = false; result.Message = "Genre name is required"; } else { var genre = _mapper.Map <Genre>(data); result = await _dbContext.Genre.Insert(genre); if (result.IsSuccess) { result.Message = "Genre added successfully!"; } } return(result); }
public async Task <IActionResult> Post([FromBody] NewGenreDto data) { var result = await _genreService.Create(data); return(new JsonResult(result)); }