public async Task <short> Handle(CreateUserBasicDataCommand request, CancellationToken cancellationToken)
            {
                UserBasicData user = new UserBasicData()
                {
                    UserName  = request.UserName,
                    FirstName = request.FirstName
                };

                _context.UserBasicData.Add(user);
                await _context.SaveChangesAsync(cancellationToken);

                return(user.UserId);
            }
Esempio n. 2
0
        public async Task <bool> Handle(DeleteGatewayCommand request, CancellationToken cancellationToken)
        {
            var entity = await _context.Gateway.FindAsync(request.GatewayId);

            if (entity == null)
            {
                throw new NotFoundException(nameof(Gateway), request.GatewayId);
            }
            entity.DeleteStatus = true;
            _context.Gateway.Update(entity);
            await _context.SaveChangesAsync(cancellationToken);

            return(true);
        }
        public async Task <string> Handle(UpdateMeterCommand request, CancellationToken cancellationToken)
        {
            var entity = await _context.Meter.FindAsync(request.MeterId);

            if (entity == null)
            {
                throw new NotFoundException(nameof(Meter), request.MeterId);
            }

            entity.VendorId = request.VendorId;
            entity.GroupId  = request.GroupId;
            entity.ModelId  = request.ModelId;

            await _context.SaveChangesAsync(cancellationToken);

            return(entity.MeterId);
        }