Пример #1
0
        public void Create(string description,
                           int price,
                           bool isAvailable,
                           DateTime deliveryDate,
                           int?typeId,
                           int unitId
                           )
        {
            Product product = new Product();

            product.Description  = description;
            product.Price        = price;
            product.IsAvailable  = isAvailable;
            product.DelivaryDate = deliveryDate;
            product.TypeId       = typeId;
            product.UnitID       = unitId;

            Unit unit = _unitRepository.Get(unitId);

            //if there is not existing unit id, do not create
            if (unit == null)
            {
                return;
            }
            product.Unit = unit;
            //check if type also exist, if not do not create
            if (typeId.HasValue && _typeRepository.Get(typeId.Value) != null)
            {
                product.Type = _typeRepository.Get(typeId.Value);
            }

            _productRepository.Add(product);
        }
Пример #2
0
        public void Create(string description,
                           double price,
                           bool isAvailable,
                           DateTime deliveryDate,
                           int typeId,
                           int unitId
                           )
        {
            UnitEntity unit = _unitRepository.Get(unitId);
            TypeEntity type = _typeRepository.Get(typeId);

            if (unit != null && type != null)
            {
                ProductEntity productEntity = new ProductEntity();
                productEntity.Description  = description;
                productEntity.Price        = price;
                productEntity.IsAvailable  = isAvailable;
                productEntity.DelivaryDate = deliveryDate;
                productEntity.TypeId       = typeId;
                productEntity.UnitID       = unitId;
                productEntity.Unit         = unit;
                productEntity.Type         = type;

                _productRepository.Add(productEntity);
            }
        }
Пример #3
0
        public async Task <Models.DTO.Device> Create(
            string userId,
            string tenantId,
            RegisterDevice device,
            CancellationToken cancellationToken)
        {
            if (!ObjectId.TryParse(device.TypeId, out var deviceId))
            {
                throw new ArgumentException("Invalid TypeId");
            }

            var type = await _typeRepository.Get(
                deviceId,
                tenantId,
                cancellationToken)
                       ??
                       throw new ArgumentException("Type not found.");

            var newDevice = DeviceMapper.MapToDomain(
                device,
                type,
                userId,
                tenantId);

            await _deviceRepository.Create(
                newDevice,
                cancellationToken);

            return(DeviceMapper.MapToDto(newDevice));
        }
Пример #4
0
        public void ValidateDelete(Type type)
        {
            Type typeById = typeRepository.Get(type.Id);

            if (typeById == null || !typeById.IsActive)
            {
                throw new BusinessLogicException("Error: Type to delete doesn't exist");
            }
        }
Пример #5
0
        public Type Get(Guid id)
        {
            Type typeById = typeRepository.Get(id);

            if (typeById == null)
            {
                throw new BusinessLogicException("Error: Invalid ID, Type does not exist");
            }
            return(typeById);
        }
 public ProductInfo(ProductInfoRaw raw, ITypeRepository typeRepository, IUnitRepository unitRepository)
 {
     ProductDescription = raw.ProductDescription;
     Price         = raw.Price;
     IsAvailable   = raw.IsAvailable;
     DeliveryDate  = raw.DeliveryDate;
     CodeType      = raw.CodeType;
     CodeUnit      = raw.CodeUnit;
     Type          = typeRepository.Get(CodeType)?.Description;
     Unit          = unitRepository.Get(CodeUnit)?.Description;
     CategoryCount = raw.CategoryCount;
     Code          = raw.Code.ToString();
 }
Пример #7
0
        public async Task <Models.DTO.Type> Get(
            string id,
            string tenantId,
            CancellationToken cancellationToken)
        {
            if (!ObjectId.TryParse(id, out var typeId))
            {
                throw new ArgumentException("Invalid Id, cannot cast to ObjectId.");
            }

            var device = await _typeRepository.Get(
                typeId,
                tenantId,
                cancellationToken);

            return(TypeMapper.MapToDto(device));
        }
Пример #8
0
        public async Task <IActionResult> Get(string typeId)
        {
            try
            {
                var type = await _typeRepository.Get(typeId);

                if (type == null)
                {
                    return(Json(NotificationMessage.TypeGetNotfound));
                }
                return(Json(type));
            }
            catch (Exception ex)
            {
                _log.LogError(ex.ToString());
                return(Json(ex.ToString()));
            }
        }
Пример #9
0
 public IList <EnterType> Get(int page)
 {
     return(_typeRepository.Get());
 }
Пример #10
0
        public IEnumerable <Data.Type> GetAll()
        {
            IEnumerable <Data.Type> items = TypeRepository.Get();

            return(items);
        }
Пример #11
0
 public Models.Type Get(int id)
 {
     Models.Type tip = _typeRepository.Get(id);
     return(_typeRepository.Get(id));
 }
Пример #12
0
        public TypeEntity Get(int id)
        {
            TypeEntity tip = _typeRepository.Get(id);

            return(_typeRepository.Get(id));
        }
Пример #13
0
 public List <TypeItem> Get()
 {
     return(iTypeRepository.Get());
 }
Пример #14
0
 public List <Type> Get()
 {
     return(typesRepository.Get());
 }
Пример #15
0
 public TypeDTO Get(int id)
 {
     return(_typeRepository.Get(id));
 }
Пример #16
0
 public IEnumerable <ProductType> Get()
 {
     return(_typeRepository.Get());
 }