public void AddProduct(ArchivedProductW aproduct)
        {
            aproduct.Id = Guid.NewGuid();
            db.ArchivedProducts.Add(aproduct.ToBase());

            db.SaveChanges();
        }
        public void EditProduct(ArchivedProductW aproduct)
        {
            //1 - edit the product properties
            var product = db.ArchivedProducts.Single(p => p.Id == aproduct.Id);

            product.Number = aproduct.Number;
            product.Name = aproduct.Name;
            product.Quantity = aproduct.Quantity;

            //2 - update numbers of the productResults
            foreach (var test in product.ArchivedProductTests)
            {
                foreach (var result in test.ArchivedProtocolResults)
                {
                    var parts = result.ResultNumber.Split('-');

                    result.ResultNumber = test.TestAcredetationLevel.Trim() + product.ArchivedDiary.Number + "-" + product.Number.ToString() +
                        (parts.Length > 2 ? "-" + parts[2].Trim() : "");
                }
            }

            db.SaveChanges();
        }