Example #1
0
        public async Task <EntityActionOutcome> UpdateEntityAsync(PeripheralInputData viewData, Guid id)
        {
            var assignedChildrenAmount = await _repository.GetChildrenAssignedToParentAsync(viewData.GatewayId);

            var validator = new PeripheralDataInputValidator();
            var result    = validator.Validate(viewData);

            if (result.IsValid == false)
            {
                return(EntityActionOutcome.UpdateFailed);
            }

            if (viewData.GatewayId != null && assignedChildrenAmount >= _assignedDevicesAmount)
            {
                return(EntityActionOutcome.PeripheralsLimitReached);
            }

            var updateSuccessful = await _repository.UpdateAsync(
                await PopulateEntityDataWithViewData(viewData, id));

            if (updateSuccessful == null)
            {
                return(EntityActionOutcome.EntityNotFound);
            }

            return(EntityActionOutcome.Success);
        }
Example #2
0
        public async Task <bool> UpdatePeripheralAsync(Peripheral peripheral)
        {
            var entity = mapper.Map <PeripheralEntity>(peripheral);

            return(await peripheralRepository.UpdateAsync(entity));
        }