// CREATE public async Task Create(ProductVersieCyclus obj) { try { // 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; } // Update object repository.Create(obj); await DB.SaveChangesAsync(); } catch (Exception) { throw; } }
// DELETE public async Task Delete(ProductVersieCyclus obj) { try { // 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; } pv.ProductVersieCyclus.Remove(pv.ProductVersieCyclus.Where(x => x.Id.Equals(obj.Id)).SingleOrDefault()); obj.Cyclus = null; await DB.SaveChangesAsync(); } catch (Exception ex) { throw; } }
public async Task Delete([FromBody] ProductVersieCyclus obj) { try { await Service.Delete(obj); } catch (Exception ex) { } }
// DELETE public void Delete(ProductVersieCyclus obj) { try { DB.ProductVersieCyclus.Remove(obj); } catch (Exception) { throw; } }
// UPDATE public void Update(ProductVersieCyclus obj) { try { DB.ProductVersieCyclus.Update(obj); } catch (Exception) { throw; } }
// CREATE public void Create(ProductVersieCyclus obj) { try { DB.ProductVersieCyclus.Add(obj); } catch (Exception) { throw; } }
// UPDATE public async Task Update(ProductVersieCyclus obj) { try { repository.Update(obj); await DB.SaveChangesAsync(); } catch (Exception) { throw; } }
public async Task <ProductVersieCyclus> GetFromID(long productCyclusMaakInstellingenID) { try { ProductVersieCyclus tmpResult = await repository.GetFromID(productCyclusMaakInstellingenID); return(tmpResult);; } catch (Exception) { throw; } }
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; } }