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); }
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); } }
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)); }
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"); } }
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(); }
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)); }
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())); } }
public IList <EnterType> Get(int page) { return(_typeRepository.Get()); }
public IEnumerable <Data.Type> GetAll() { IEnumerable <Data.Type> items = TypeRepository.Get(); return(items); }
public Models.Type Get(int id) { Models.Type tip = _typeRepository.Get(id); return(_typeRepository.Get(id)); }
public TypeEntity Get(int id) { TypeEntity tip = _typeRepository.Get(id); return(_typeRepository.Get(id)); }
public List <TypeItem> Get() { return(iTypeRepository.Get()); }
public List <Type> Get() { return(typesRepository.Get()); }
public TypeDTO Get(int id) { return(_typeRepository.Get(id)); }
public IEnumerable <ProductType> Get() { return(_typeRepository.Get()); }