Exemple #1
0
        public GatewayTypeDto Update(CreateGatewayTypeDto input)
        {
            var entity = _gatewayTypeRepository.Get(input.Id);

            ObjectMapper.Map(input, entity);
            var result = _gatewayTypeRepository.Update(entity);

            CurrentUnitOfWork.SaveChanges();
            return(ObjectMapper.Map <GatewayTypeDto>(result));
        }
Exemple #2
0
        public GatewayTypeDto Create(CreateGatewayTypeDto input)
        {
            var query = _gatewayTypeRepository.GetAll().Where(gt => gt.TypeId == input.TypeId ||
                                                              gt.TypeName == input.TypeName);

            if (query.Any())
            {
                throw new ApplicationException("网关类型已存在");
            }

            var entity = ObjectMapper.Map <GatewayType>(input);
            var result = _gatewayTypeRepository.Insert(entity);

            CurrentUnitOfWork.SaveChanges();
            return(ObjectMapper.Map <GatewayTypeDto>(result));
        }