Пример #1
0
 static MongoDataContext()
 {
     ProductMapping.Register();
     MachineMapping.Register();
     ProjectMapping.Register();
     AddressMapping.Register();
 }
Пример #2
0
        public async Task <IEnumerable <OutMachineDTO> > GetMachinesOfMachineTypeByMachineTypeIdAsync(int machineTypeId)
        {
            Expression <Func <Machine, bool> > withMachineType = m => m.MachineType.Id.Equals(machineTypeId);
            var machines = await _machineRepository.GetWhere(withMachineType, 0, 100);

            return(MachineMapping.MachineToOutDto(machines));
        }
Пример #3
0
        public async Task <OutMachineDTO> CreatMachineAsync(InMachineDTO machineDto)
        {
            var newMachine = MachineMapping.InDtoToMachine(machineDto);

            newMachine.MachineType = await _machineTypeRepository.GetById(machineDto.MachineType);

            var machine = await _machineRepository.Create(newMachine);

            var outMachineDto = MachineMapping.MachineToOutDto(machine);

            return(outMachineDto);
        }
Пример #4
0
        public async Task <OutMachineDTO> UpdateMachineAsync(int id, InMachineDTO machineDto)
        {
            var machine = await _machineRepository.GetById(id);

            if (machine != null)
            {
                Machine machineMapping = MachineMapping.InDtoToMachine(machineDto);
                machine.Description = machineMapping.Description;
                machine.MachineName = machineMapping.MachineName;
                var machineType = await _machineTypeRepository.GetById(machineDto.MachineType);

                machine.MachineType = machineType;
                machine.Active      = machineMapping.Active;
            }
            var createdMachine = await _machineRepository.Update(machine);

            var outMachineDto = MachineMapping.MachineToOutDto(createdMachine);

            return(outMachineDto);
        }
Пример #5
0
 public Task <BoolResult> ForceRegisterMachineAsync(OperationContext context, MachineMapping mapping)
 {
     throw new NotImplementedException($"Attempt to use {nameof(ClientGlobalCacheStore)} for machine registration is unsupported");
 }
Пример #6
0
        public async Task <IEnumerable <OutMachineDTO> > GetMachines(int @from, int take)
        {
            var machines = await _machineRepository.GetAll(from, take);

            return(MachineMapping.MachineToOutDto(machines));
        }
Пример #7
0
        public async Task <OutMachineDTO> GetByNameAsync(string name)
        {
            var machine = await _machineRepository.GetByName(name);

            return(MachineMapping.MachineToOutDto(machine));
        }
Пример #8
0
        public async Task <OutMachineDTO> GetByIdAsync(int id)
        {
            var machine = await _machineRepository.GetById(id);

            return(MachineMapping.MachineToOutDto(machine));
        }