public async Task <IActionResult> UpdateAssociation(AssociationDto input) { if (input == null) { return(BadRequest()); } var association = await _associationsService.UpdateAssociation(input); if (association == null) { return(BadRequest()); } return(Ok(association)); }
public async Task <AssociationDto> UpdateAssociation(AssociationDto input) { if (input == null) { return(null); } var association = ObjectMapper.Map <Association>(input); var associationUpdated = await _associationRepository.UpdateAsync(association); var associationToReturn = ObjectMapper.Map <AssociationDto>(associationUpdated); return(associationToReturn); }
public async Task <int> CreateAssociation(AssociationDto input) { if (input == null) { return(-1); } var association = ObjectMapper.Map <Association>(input); association.Discoverable = false; association.SortingOrder = association.Id; association.TimeZone = DateTime.UtcNow.ToString(); association.LaunchDate = association.CreationTime; await _associationRepository.InsertAndGetIdAsync(association); return(association.Id); }
public async Task <AssociationDto> UpdateAssociation(int id, AssociationDto input) { if (input == null) { return(null); } //check if id exists var checkIfAssociationExist = await _associationRepository.GetAll().AnyAsync(c => c.Id == id); if (!checkIfAssociationExist) { return(null); } var association = ObjectMapper.Map <Association>(input); association.Id = id; var associationUpdated = await _associationRepository.UpdateAsync(association); var associationToReturn = ObjectMapper.Map <AssociationDto>(associationUpdated); return(associationToReturn); }