Esempio n. 1
0
        public Task <bool> Handle(UpdateBongCommand message, CancellationToken cancellationToken)
        {
            if (!message.IsValid())
            {
                NotifyValidationErrors(message);
                return(Task.FromResult(false));
            }

            var Bong         = new Bong(message.Id, message.Name, message.ReferenceNo, message.ArrivingInStock);
            var existingBong = _BongRepository.GetByReferenceNo(Bong.ReferenceNo);

            if (existingBong != null && existingBong.Id != Bong.Id)
            {
                if (!existingBong.Equals(Bong))
                {
                    Bus.RaiseEvent(new DomainNotification(message.MessageType, "The Bong ref no has already been taken."));
                    return(Task.FromResult(false));
                }
            }

            _BongRepository.Update(Bong);

            if (Commit())
            {
                Bus.RaiseEvent(new BongUpdatedEvent(Bong.Id, Bong.Name, Bong.ReferenceNo, Bong.ArrivingInStock));
            }

            return(Task.FromResult(true));
        }
Esempio n. 2
0
        public Task <bool> Handle(RegisterNewBongCommand message, CancellationToken cancellationToken)
        {
            if (!message.IsValid())
            {
                NotifyValidationErrors(message);
                return(Task.FromResult(false));
            }

            var Bong = new Bong(Guid.NewGuid(), message.Name, message.ReferenceNo, message.ArrivingInStock);

            if (_BongRepository.GetByReferenceNo(Bong.ReferenceNo) != null)
            {
                Bus.RaiseEvent(new DomainNotification(message.MessageType, "The Bong e-mail has already been taken."));
                return(Task.FromResult(false));
            }

            _BongRepository.Add(Bong);

            if (Commit())
            {
                Bus.RaiseEvent(new BongRegisteredEvent(Bong.Id, Bong.Name, Bong.ReferenceNo, Bong.ArrivingInStock));
            }

            return(Task.FromResult(true));
        }
    public string GetProductInfo(Product product)
    {
        switch (product.productType)
        {
        case Product.type_.storageJar:
            StorageJar jar = (StorageJar)product;
            return("Strain: " + jar.GetStrain().name);

        case Product.type_.glassBong:
        case Product.type_.acrylicBong:
            Bong bong = (Bong)product;
            return("Height: " + bong.height);

        case Product.type_.glassPipe:
        case Product.type_.acrylicPipe:
            Pipe pipe = (Pipe)product;
            return("Length: " + pipe.length);

        case Product.type_.rollingPaper:
            RollingPaper paper = (RollingPaper)product;
            return(paper.paperType.ToString());

        case Product.type_.edible:
            Edible edible = (Edible)product;
            return(edible.edibleType.ToString());

        case Product.type_.box:
            StorageBox box = (StorageBox)product;
            return("Products: " + box.products.Count);
        }
        return("ProductType");
    }
Esempio n. 4
0
 public IActionResult Post([FromBody] Bong newBong)
 {
     using (BurgerContext context = new BurgerContext())
     {
         context.Bongs.Add(newBong);
         context.SaveChanges();
     }
     return(Created("/burger", newBong));
 }
Esempio n. 5
0
    public float GenerateInterest(Product product)
    {
        float interestValue = 50;

        if (desiredProducts.Count > 0)
        {
            foreach (Product desiredProduct in desiredProducts)
            {
                if (product.productType == desiredProduct.referenceType)
                {
                    interestValue += 20;
                    switch (product.productType)
                    {
                    case Product.type_.glassPipe:
                    case Product.type_.acrylicPipe:
                        Pipe         pipe             = (Pipe)product;
                        DesiredGlass glassPipe        = (DesiredGlass)desiredProduct;
                        float        inspectingLength = pipe.length;
                        float        desiredLength    = glassPipe.height;
                        float        lengthDifference = Mathf.Abs(inspectingLength - desiredLength);
                        int          pipeInterest     = (int)MapValue(0, 25, 30, 0, lengthDifference); // Take a difference of 0-25 and convert it respectively to a range of 30-0
                        interestValue += pipeInterest;
                        break;

                    case Product.type_.glassBong:
                    case Product.type_.acrylicBong:
                        Bong         bong             = (Bong)product;
                        DesiredGlass glassBong        = (DesiredGlass)desiredProduct;
                        float        inspectingHeight = bong.height;
                        float        desiredHeight    = glassBong.height;
                        float        heightDifference = Mathf.Abs(inspectingHeight - desiredHeight);
                        int          bongInterest     = (int)MapValue(0, 22, 30, 0, heightDifference); // Take a difference of 0-22 and convert it respectively to a range of 30-0
                        interestValue += bongInterest;
                        break;

                    case Product.type_.edible:
                        Edible        edible        = (Edible)product;
                        DesiredEdible desiredEdible = (DesiredEdible)desiredProduct;
                        if (edible.edibleType == desiredEdible.desiredType)
                        {
                            float thcDifference  = Mathf.Abs(edible.THCpercent - desiredEdible.desiredTHC);
                            int   edibleInterest = (int)MapValue(0, 250, 30, 0, thcDifference);   // Take a difference of 0-250 and convert it respectively to a range of 30-0
                            interestValue += edibleInterest;
                        }
                        break;

                    case Product.type_.rollingPaper:
                        RollingPaper paper        = (RollingPaper)product;
                        DesiredPaper desiredPaper = (DesiredPaper)desiredProduct;
                        if (paper.paperType == desiredPaper.desiredType)
                        {
                            interestValue += 30;
                        }
                        break;
                    }
                }
            }
        }
        if (desiredStrains.Count > 0 && product.GetProductType() == Product.type_.storageJar)
        {
            interestValue += 10;
            StorageJar jar            = (StorageJar)product;
            Strain     bestMatch      = null;
            float      bestMatchValue = 50;
            foreach (DesiredStrain strain in desiredStrains)
            {
                float matchValue = StrainTypeMatch(strain.strain, jar.GetStrain());
                if (matchValue > bestMatchValue)
                {
                    bestMatch      = strain.strain;
                    bestMatchValue = matchValue;
                }
            }
            if (bestMatch != null)
            {
                int strainInterest = (int)MapValue(0, 100, 0, 40, bestMatchValue);
                interestValue += strainInterest;
            }
        }
        print(customerName + ": " + product.GetName() + " " + interestValue);
        return(interestValue);
    }
Esempio n. 6
0
 public Bong_s(Bong bong) : base(Product.type_.glassBong, bong.uniqueID, bong.objectID, bong.subID, bong.GetName(), bong.productGO.transform.position, bong.productGO.transform.eulerAngles)
 {
     height = bong.height;
 }
    public Product CreateProduct(StoreObjectReference toCreate, Vector3 pos)
    {
        GameObject newProductGameObject = Instantiate(toCreate.gameObject_);
        ProductGO  newProductGO         = newProductGameObject.GetComponent <ProductGO>();

        newProductGO.transform.position = pos;
        newProductGO.gameObject.SetActive(false);
        if (toCreate.color.colorIsAssigned)
        {
            newProductGameObject = ApplyColor(newProductGameObject, toCreate.color.color);
        }

        /*if (newProductGO.colorable)
         * {
         *  if (toCreate.randomColor != null)
         *  {
         *      newProductGameObject = ApplyColor(newProductGameObject, toCreate.randomColor);
         *  }
         *  else
         *  {
         *      newProductGameObject = ApplyRandomColor(newProductGameObject);
         *  }
         * }*/
        Product.type_ productType;
        switch (toCreate.proType)
        {
        case StoreObjectReference.productType.jar:
            productType = Product.type_.storageJar;
            break;

        case StoreObjectReference.productType.glassBong:
            productType = Product.type_.glassBong;
            break;

        case StoreObjectReference.productType.acrylicBong:
            productType = Product.type_.acrylicBong;
            break;

        case StoreObjectReference.productType.glassPipe:
            productType = Product.type_.glassPipe;
            break;

        case StoreObjectReference.productType.acrylicPipe:
            productType = Product.type_.acrylicPipe;
            break;

        case StoreObjectReference.productType.rollingPaper:
            productType = Product.type_.rollingPaper;
            break;

        case StoreObjectReference.productType.edible:
            productType = Product.type_.edible;
            break;

        case StoreObjectReference.productType.bowl:
            productType = Product.type_.bowl;
            break;

        case StoreObjectReference.productType.grinder:
            productType = Product.type_.grinder;
            break;

        default:
            productType = Product.type_.reference;
            break;
        }
        newProductGO.objectID = toCreate.objectID;
        switch (productType)
        {
        case Product.type_.glassBong:
        case Product.type_.acrylicBong:
            Bong newBong = new Bong(toCreate, newProductGameObject);
            newBong.uniqueID     = Dispensary.GetUniqueProductID();
            newBong.objectID     = toCreate.objectID;
            newBong.boxWeight    = toCreate.boxWeight;
            newProductGO.product = newBong;
            return(newBong);

        case Product.type_.glassPipe:
        case Product.type_.acrylicPipe:
            Pipe newPipe = new Pipe(toCreate, newProductGameObject);
            newPipe.uniqueID     = Dispensary.GetUniqueProductID();
            newPipe.objectID     = toCreate.objectID;
            newPipe.boxWeight    = toCreate.boxWeight;
            newProductGO.product = newPipe;
            return(newPipe);

        case Product.type_.storageJar:
            StorageJar newJar = new StorageJar(toCreate, newProductGameObject);
            newJar.uniqueID      = Dispensary.GetUniqueProductID();
            newJar.objectID      = toCreate.objectID;
            newJar.boxWeight     = toCreate.boxWeight;
            newProductGO.product = newJar;
            return(newJar);

        case Product.type_.bowl:
            Bowl newBowl = new Bowl(toCreate, newProductGameObject);
            newBowl.uniqueID     = Dispensary.GetUniqueProductID();
            newBowl.objectID     = toCreate.objectID;
            newBowl.boxWeight    = toCreate.boxWeight;
            newProductGO.product = newBowl;
            //newBowl = (Bowl)ApplyRandomColor(newBowl);
            return(newBowl);

        case Product.type_.grinder:
            Grinder newGrinder = new Grinder(toCreate, newProductGameObject);
            newGrinder.uniqueID  = Dispensary.GetUniqueProductID();
            newGrinder.objectID  = toCreate.objectID;
            newGrinder.boxWeight = toCreate.boxWeight;
            newProductGO.product = newGrinder;
            //newGrinder = (Grinder)ApplyRandomColor(newGrinder);
            return(newGrinder);
        }
        return(null);
    }