Ejemplo n.º 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);
        }
Ejemplo n.º 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);
            }
        }
Ejemplo n.º 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));
        }
Ejemplo n.º 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");
            }
        }
Ejemplo n.º 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();
 }
Ejemplo n.º 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));
        }
Ejemplo n.º 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()));
            }
        }
Ejemplo n.º 9
0
 public IList <EnterType> Get(int page)
 {
     return(_typeRepository.Get());
 }
Ejemplo n.º 10
0
        public IEnumerable <Data.Type> GetAll()
        {
            IEnumerable <Data.Type> items = TypeRepository.Get();

            return(items);
        }
Ejemplo n.º 11
0
 public Models.Type Get(int id)
 {
     Models.Type tip = _typeRepository.Get(id);
     return(_typeRepository.Get(id));
 }
Ejemplo n.º 12
0
        public TypeEntity Get(int id)
        {
            TypeEntity tip = _typeRepository.Get(id);

            return(_typeRepository.Get(id));
        }
Ejemplo n.º 13
0
 public List <TypeItem> Get()
 {
     return(iTypeRepository.Get());
 }
Ejemplo n.º 14
0
 public List <Type> Get()
 {
     return(typesRepository.Get());
 }
Ejemplo n.º 15
0
 public TypeDTO Get(int id)
 {
     return(_typeRepository.Get(id));
 }
Ejemplo n.º 16
0
 public IEnumerable <ProductType> Get()
 {
     return(_typeRepository.Get());
 }