public IActionResult CreateResource([FromBody] CreateResourceDto input) { if (input == null) { return(new BadRequestObjectResult(ModelState)); } if (!ModelState.IsValid) { return(new BadRequestObjectResult(ModelState)); } var languageRepo = _sqlUnitOfWork.Repository <Language>(); var resourceRepo = _sqlUnitOfWork.Repository <Resource>(); if (languageRepo.FirstOrDefault(k => k.Id == input.LanguageId) == null) { return(new NotFoundObjectResult(new { Input = input, error = $"There was no 'Language' with an id of {input.LanguageId}." })); } var newResource = new Resource { ObjectState = Contracts.ObjectState.Added, LanguageId = input.LanguageId, Key = input.Key, Value = input.Value, Comment = input.Comment }; resourceRepo.SaveAllChanges(newResource); _cacheProvider.Remove(nameof(Resource)); return(new OkObjectResult(newResource)); }
public async Task <IActionResult> CreateOneAsync( [FromBody] CreateResourceDto resource ) { try { var item = await _resourceService.CreateOneAsync(resource.ToEntity()); return(Ok(item)); } catch (Exception e) { return(HttpExceptionMapper.ToHttpActionResult(e)); } }
public Task <ResourceDto> CreateAsync(CreateResourceDto input) { throw new NotImplementedException(); }