// UPDATE
        public async Task Update(ProductEigenschap obj)
        {
            try
            {
                // Update Eigenschap
                repository.Update(obj);

                // Reset Product Versie status naar "Test"
                ProductVersie pv = await productVersieRepository.GetFrom(obj.ProductVersieId);

                if (pv == null)
                {
                    return;
                }

                if (pv.Status.Equals(2))
                // Als de Product Versie status "productie" heeft, omschakelen naar "test" status
                {
                    pv.Status = 1;
                }

                // Save to DB
                await DB.SaveChangesAsync();
            }
            catch (Exception ex)
            {
                throw;
            }
        }
示例#2
0
        public async Task <ProductVersie> NewVersieFromTemplate(Product product, float hoogteVersie)
        // Maak een nieuwe product versie op basis van de template eigenschappen
        {
            // Maak nieuwe versie aan
            ProductVersie newProductVersie = new ProductVersie();

            newProductVersie.Id        = 0;
            newProductVersie.ProductId = product.Id;
            newProductVersie.Naam      = "Nieuw";
            newProductVersie.Versie    = hoogteVersie + 1;
            newProductVersie.Status    = 0;


            //  Zoek alle Eigenschappen van deze pool
            List <Eigenschap> tmplEigenschappen = await this.eigenschapService.GetFromMachineOnderdeel(product.MachineOnderdeelId);

            foreach (Eigenschap item in tmplEigenschappen)
            // Voeg Alle templates toe als Blanco Product Eigensap
            {
                ProductEigenschap pe = new ProductEigenschap();
                pe.Id = 0;
                pe.ProductVersieId = newProductVersie.Id;
                pe.EigenschapId    = item.Id;
                pe.Waarde          = "";
                pe.Check           = false;

                newProductVersie.ProductEigenschap.Add(pe);
            }

            return(newProductVersie);
        }
示例#3
0
 public async Task Delete([FromBody] ProductEigenschap obj)
 {
     try
     {
         await Service.Delete(obj);
     }
     catch (Exception ex)
     {
     }
 }
 // DELETE
 public void Delete(ProductEigenschap obj)
 {
     try
     {
         DB.ProductEigenschap.Remove(obj);
     }
     catch (Exception)
     {
         throw;
     }
 }
 // UPDATE
 public void Update(ProductEigenschap obj)
 {
     try
     {
         DB.ProductEigenschap.Update(obj);
     }
     catch (Exception)
     {
         throw;
     }
 }
 // CREATE
 public void Create(ProductEigenschap obj)
 {
     try
     {
         DB.ProductEigenschap.Add(obj);
     }
     catch (Exception)
     {
         throw;
     }
 }
 // DELETE
 public async Task Delete(ProductEigenschap obj)
 {
     try
     {
         repository.Delete(obj);
         await DB.SaveChangesAsync();
     }
     catch (Exception)
     {
         throw;
     }
 }
示例#8
0
        // Waarde van maakinstelling uit product eigenschappen halen en actualiseren.
        private void UpdateWaardeVanEigenschap(ref ProductVersie pv)
        {
            if (pv == null)
            {
                return;
            }

            if (pv.ProductVersieCyclus == null)
            {
                return;
            }

            foreach (ProductVersieCyclus cyclus in pv.ProductVersieCyclus)
            // Alle Cyclussen aflopen
            {
                foreach (CyclusMaakInstelling item in cyclus.Cyclus.CyclusMaakInstelling)
                // Alle Cyclus maak instellingen aflopen en bijwerken
                {
                    if (item.ProductEigenschap == null)
                    // Als er geen onderliggend product eigenschap is, gebruik dan de static waarde
                    {
                        item.Waarde = item.StaticWaarde;
                        continue;
                    }

                    ProductEigenschap productEigenschap = pv.ProductEigenschap.Where(x => x.Eigenschap.Id.Equals(item.ProductEigenschap.Id)).FirstOrDefault();

                    if (productEigenschap == null)
                    // Geen product eigenschap
                    {
                        item.Waarde = "";
                        continue;
                    }

                    if (string.IsNullOrEmpty(productEigenschap.Waarde))
                    // Geen waarde in product eigenschap
                    {
                        item.Waarde = "";
                    }

                    // Waarde is beschikbaar
                    item.Waarde = productEigenschap.Waarde;
                }
            }
        }
示例#9
0
        public async Task <ProductVersie> Copy(ProductVersie sourceProductVersie, long productID)
        // Maak een nieuw product versie aan en copy alle onderliggende eigenschappen en cyclus instellingen
        {
            try
            {
                ProductVersie newPV = new ProductVersie();
                newPV.Id        = 0;
                newPV.ProductId = productID;
                newPV.Foto      = sourceProductVersie.Foto;
                newPV.Cad3d     = sourceProductVersie.Cad3d;
                newPV.Cad2d     = sourceProductVersie.Cad2d;
                newPV.Pdf       = sourceProductVersie.Pdf;
                newPV.Naam      = sourceProductVersie.Naam;
                newPV.Versie    = 1;
                newPV.Status    = 0;

                newPV.Product = null;



                // Eigenschappen kopieren
                if (sourceProductVersie.ProductEigenschap != null)
                // Er zijn product eigenschappen in de source versie
                {
                    foreach (ProductEigenschap pe in sourceProductVersie.ProductEigenschap)
                    {
                        ProductEigenschap newPe = new ProductEigenschap();
                        newPe.Id = 0;
                        newPe.ProductVersieId = 0;
                        newPe.EigenschapId    = pe.EigenschapId;
                        newPe.Waarde          = pe.Waarde;
                        newPe.Check           = pe.Check;

                        newPe.Eigenschap    = null;
                        newPe.ProductVersie = null;

                        newPV.ProductEigenschap.Add(newPe); // Nieuwe product eigenschap toevoegen aan product versie
                    }
                }



                // Versie Maak Instellingen
                if (sourceProductVersie.ProductVersieCyclus != null)
                {
                    foreach (ProductVersieCyclus pvc in sourceProductVersie.ProductVersieCyclus)
                    {
                        ProductVersieCyclus newpvc = new ProductVersieCyclus();
                        newpvc.Id = 0;
                        newpvc.ProductVersieId = 0;
                        newpvc.CyclusId        = pvc.CyclusId;

                        newpvc.Cyclus = null;

                        newpvc.ProductVersie = null;

                        newPV.ProductVersieCyclus.Add(newpvc); // Nieuwe product versie cyclus  toevoegen aan product versie
                    }
                }


                return(newPV);
            }
            catch (Exception ex)
            {
                throw;
            }
        }