public async Task <ActionResult <TypeResource> > CreateType([FromBody] SaveTypeResource saveTypeResource) { var validator = new SaveTypeResourceValidator(); var validationResult = await validator.ValidateAsync(saveTypeResource); if (!validationResult.IsValid) { return(BadRequest(validationResult.Errors)); // this needs refining, but for demo it is ok } var typeToCreate = _mapper.Map <SaveTypeResource, Type>(saveTypeResource); var newType = await _typeService.CreateType(typeToCreate); var type = await _typeService.GetTypeById(newType.Id); var typeResource = _mapper.Map <Type, TypeResource>(type); return(Ok(typeResource)); }
public ActionResult <AvatarType> Post([FromBody] AvatarType aType) { return(_typeService.CreateType(aType)); }