public async Task <IActionResult> GetRlationsCountByType(int id, int type) { if (await _repository.GetIndividualAsync(id) == null) { return(NotFound("Individual Could not be found")); } var relationCount = await _repository.GetRelationCountAsync(id, (RelationType)type); return(Ok(relationCount)); }
public async Task <ActionResult <IndividualModel> > Get(int id) { var result = await _repository.GetIndividualAsync(id); if (result == null) { return(NotFound(_localizer["Individual could not be found"])); } var model = _mapper.Map <IndividualModel>(result); if (!string.IsNullOrEmpty(result.Image)) { model.Image = _imageWriter.GetImage(result.Image); } return(Ok(model)); }
public async Task <IActionResult> UploadImage(IFormFile file, int id) { var individual = await _repository.GetIndividualAsync(id); if (!string.IsNullOrEmpty(individual.Image)) { _imageWriter.DeleteImage(individual.Image); } var newImageLocation = await _imageWriter.UploadImage(file); individual.Image = newImageLocation; if (await _repository.SaveChangesAsync()) { return(Ok()); } return(BadRequest()); }