コード例 #1
0
        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));
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        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);
        }
コード例 #4
0
        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);
        }