Example #1
0
 public void Insert(T entity)
 {
     entity.DateCreated = DateTime.Now;
     entity.DateChanged = DateTime.Now;
     entity.Active      = true;
     context.Set <T>().Add(entity);
     context.SaveChanges();
 }
        public ActionResult Create(Contact contact)
        {
            if (ModelState.IsValid)
            {
                db.Contacts.Add(contact);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(contact));
        }
Example #3
0
 public bool CallBack(Cargo cargo)
 {
     if (cargo != null)
     {
         bool IsExist = CargoViewModels.Any <CargoViewModel>
                            (item => item.Cargo.PreciseCargoName == cargo.PreciseCargoName);
         if (!IsExist)
         {
             CargoViewModel cargoViewModel = new CargoViewModel(CMContext);
             cargoViewModel.Cargo                     = cargo;
             cargoViewModel.CargoViewModels           = CargoViewModels;
             cargoViewModel.CargoCollectionViewModels = CargoCollectionViewModels;
             CMContext.Cargo.Add(cargo);
             CMContext.SaveChanges();
             CargoViewModels.Add(cargoViewModel);
             return(false);
         }
         else
         {
             return(true);
         }
     }
     else
     {
         return(false);
     }
 }
 public bool CallBack(Block block)
 {
     if (block != null)
     {
         bool IsExist = BlockViewModels.Any <BlockViewModel>
                            (item => item.Block.BlockName == block.BlockName);
         if (!IsExist)
         {
             block.WarehouseName = Plane.WarehouseName;
             block.PlaneName     = Plane.PlaneName;
             BlockViewModel newBlockViewModel = new BlockViewModel(CMContext)
             {
                 Block          = block,
                 PlaneViewModel = this
             };
             CMContext.Block.Add(block);
             BlockViewModels.Add(newBlockViewModel);
             CMContext.SaveChanges();
             return(false);
         }
         else
         {
             return(true);
         }
     }
     else
     {
         return(false);
     }
 }
Example #5
0
        public async Task Return_Correct_Updated_IngredientType()
        {
            var options = Utils.GetOptions(nameof(Return_Correct_Updated_IngredientType));

            var ingredientType = new IngredientType()
            {
                Id   = Guid.Parse("4a399308-dec0-4161-a679-18b4898c7e4b"),
                Name = "Liqeur"
            };

            using (var arrangeContext = new CMContext(options))
            {
                arrangeContext.IngredientTypes.Add(ingredientType);
                arrangeContext.SaveChanges();
            }

            var newName = "Liqeurr";

            using (var assertContext = new CMContext(options))
            {
                var sut    = new IngredientTypeService(assertContext);
                var result = await sut.UpdateIngredientType(ingredientType.Id, newName);

                Assert.AreEqual(ingredientType.Id, result.Id);
                Assert.AreEqual(newName, result.Name);
            }
        }
 public bool CallBack(Warehouse warehouse)
 {
     if (warehouse != null)
     {
         bool IsExist = WarehouseViewModels.Any <WarehouseViewModel>
                            (item => item.Warehouse.WarehouseName == warehouse.WarehouseName);
         if (!IsExist)
         {
             WarehouseViewModel warehouseViewModel = new WarehouseViewModel(CMContext)
             {
                 Warehouse = warehouse,
                 WarehouseRootViewModel = this
             };
             CMContext.Warehouse.Add(warehouse);
             WarehouseViewModels.Add(warehouseViewModel);
             CMContext.SaveChanges();
             return(false);
         }
         else
         {
             return(true);
         }
     }
     else
     {
         return(false);
     }
 }
        private void AddImageExecute(object parameter)
        {
            OpenFileDialog dlg = new OpenFileDialog();

            // Set filter for file extension and default file extension
            dlg.DefaultExt = ".png";
            dlg.Filter     = "ALL Files (*.png, *.jpg, *.jpeg, *.gif, *.bmp)|*.png;*.jpg;*.jpeg;*.gif;*.bmp|JPEG Files (*.jpeg)|*.jpeg|PNG Files (*.png)|*.png|JPG Files (*.jpg)|*.jpg|GIF Files (*.gif)|*.gif";


            // Display OpenFileDialog by calling ShowDialog method
            Nullable <bool> result = dlg.ShowDialog();


            // Get the selected file name and display in a TextBox
            if (result == true)
            {
                // Open document
                ImagePath = dlg.FileName;
                FileStream fs     = new FileStream(ImagePath, FileMode.Open);
                byte[]     byData = new byte[fs.Length];
                fs.Read(byData, 0, byData.Length);
                fs.Close();
                Cargo.CargoImage = byData;
                CMContext.SaveChanges();
            }
        }
Example #8
0
 public void DeleteCargoCollection()
 {
     BlockViewModel.CargoCollectionViewModels.Remove(this);
     CargoCollectionViewModels.Remove(this);
     CMContext.CargoCollection.Remove(CargoCollection);
     CMContext.SaveChanges();
 }
        private void ConfirmPurchaseOrderCollectionExecute(object parameter)
        {
            string       message       = "是否确认订单";
            string       detailMessage = "请检查进货订单中的每一个条目是否正确,确认订单后将无法修改";
            PromptWindow prompt        = new PromptWindow(message, detailMessage);
            bool?        IsConfirmed   = prompt.ShowDialog();

            if (IsConfirmed == true)
            {
                DateTime CurrentTime = DateTime.Now;
                PurchaseOrderCollectionViewModel.PurchaseOrderCollection.PurchaseTime = CurrentTime;
                foreach (var purchaseorderviewmodel in PurchaseOrderCollectionViewModel.PurchaseOrderViewModels)
                {
                    purchaseorderviewmodel.PurchaseOrder.PurchaseTime = CurrentTime;
                    CMContext.PurchaseOrder.Add(purchaseorderviewmodel.PurchaseOrder);
                    BlockViewModel blockViewModel             = purchaseorderviewmodel.BlockViewModel;
                    IEnumerable <CargoCollectionViewModel> cc = blockViewModel.CargoCollectionViewModels.Where <CargoCollectionViewModel>(item => item.CargoCollection.PreciseCargoName == purchaseorderviewmodel.PurchaseOrder.PreciseCargoName);
                    if (cc.Count() == 0)
                    {
                        CargoCollectionViewModel c = new CargoCollectionViewModel(CMContext, purchaseorderviewmodel)
                        {
                            BlockViewModel = blockViewModel, CargoCollectionViewModels = CargoCollectionViewModels
                        };
                        CargoCollectionViewModels.Add(c);
                        blockViewModel.CargoCollectionViewModels.Add(c);
                        CMContext.CargoCollection.Add(c.CargoCollection);
                        PurchasePrizeDic p1 = new PurchasePrizeDic(purchaseorderviewmodel.PurchaseOrder)
                        {
                            UnitPurchasePrize = -1
                        };
                        PurchasePrizeDic p2 = new PurchasePrizeDic(purchaseorderviewmodel.PurchaseOrder);
                        CMContext.PurchasePrizeDic.Add(p1);
                        CMContext.PurchasePrizeDic.Add(p2);
                        c.SelectedPurchasePrizeDic = p1;
                    }
                    else
                    {
                        CargoCollectionViewModel c = cc.First();
                        c.CargoCollection.Amount += purchaseorderviewmodel.PurchaseOrder.Amount;
                        c.CargoCollection.PurchasePrizeDics[0].Amount = c.CargoCollection.Amount;
                        IEnumerable <PurchasePrizeDic> pp = c.CargoCollection.PurchasePrizeDics.Where <PurchasePrizeDic>(item => item.UnitPurchasePrize == purchaseorderviewmodel.PurchaseOrder.UnitPurchasePrize);
                        if (pp.Count() == 0)
                        {
                            PurchasePrizeDic p = new PurchasePrizeDic(purchaseorderviewmodel.PurchaseOrder);
                            CMContext.PurchasePrizeDic.Add(p);
                        }
                        else
                        {
                            pp.First().Amount += purchaseorderviewmodel.PurchaseOrder.Amount;
                        }
                    }
                }
                CMContext.PurchaseOrderCollection.Add(PurchaseOrderCollectionViewModel.PurchaseOrderCollection);
                PurchaseOrderCollectionViewModels.Add(PurchaseOrderCollectionViewModel);
                CMContext.SaveChanges();
                PurchaseOrderCollectionViewModel = null;
                OutPurchaseOrderButtonIsEnabled  = false;
            }
        }
        private void DeleteExecute(object parameter)
        {
            string       message       = "是否删除卖货订单";
            string       detailMessage = "删除的卖货订单记录将无法恢复,请确认是否是删除该订单\n删除之前备份订单的信息以便错误删除后进行恢复";
            PromptWindow prompt        = new PromptWindow(message, detailMessage);
            bool?        IsConfirmed   = prompt.ShowDialog();

            if (IsConfirmed == true)
            {
                SellOrderCollectionViewModels.Remove(this);
                CMContext.SellOrderCollection.Remove(SellOrderCollection);
                CMContext.SaveChanges();
            }
        }
        public async Task Return_True_If_Bar_Has_Cocktail()
        {
            var options = Utils.GetOptions(nameof(Return_True_If_Bar_Has_Cocktail));

            var bar = new Bar()
            {
                Id          = Guid.Parse("1f573fa6-3cc0-48ad-8850-ee7675cc3096"),
                Name        = "Konyushnite",
                Phone       = "0899516116",
                Website     = "-",
                Description = "Live music",
                CityId      = Guid.Parse("e3e92ad8-b117-42a8-b263-ec351d9234fc"),
                Address     = "40 Saborna Str."
            };

            var cocktail = new Cocktail
            {
                Id          = Guid.Parse("9ef97551-87f6-40ce-a88b-6c0e876ccb51"),
                Name        = "Margarita",
                Description = "The Margarita is one of the most " +
                              "popular cocktails in North America—for good reason. " +
                              "Combining the tang of lime and the sweetness of o" +
                              "range liqueur with the distinctive strength of " +
                              "tequila, our classic Margarita strikes all of the right keys."
            };

            var barCocktail = new BarCocktail
            {
                CocktailId = cocktail.Id,
                BarId      = bar.Id,
                UnlistedOn = null
            };

            using (var arrangeContext = new CMContext(options))
            {
                arrangeContext.Bars.Add(bar);
                arrangeContext.Cocktails.Add(cocktail);
                arrangeContext.BarCocktails.Add(barCocktail);

                arrangeContext.SaveChanges();
            }

            using (var assertContext = new CMContext(options))
            {
                var sut    = new CocktailService(assertContext);
                var result = await sut.IsCocktailAvailableInBar(barCocktail.BarId, barCocktail.CocktailId);

                Assert.IsTrue(result);
            }
        }
Example #12
0
        public async Task Return_Correct_IsUnlisted()
        {
            var options = Utils.GetOptions(nameof(Return_Correct_IsUnlisted));

            var ingredient = new Ingredient
            {
                Id          = Guid.Parse("4039e0f3-8d2d-43a5-a82b-477e42371cd6"),
                Name        = "Martini Extra Dry",
                Abv         = 0,
                Description = "",
                TypeId      = Guid.Parse("619ac43c-075a-47be-befc-c68249054b85"),
            };

            var cocktail = new Cocktail
            {
                Id          = Guid.Parse("9ef97551-87f6-40ce-a88b-6c0e876ccb51"),
                Name        = "Margarita",
                Description = "The Margarita is one of the most " +
                              "popular cocktails in North America—for good reason. " +
                              "Combining the tang of lime and the sweetness of o" +
                              "range liqueur with the distinctive strength of " +
                              "tequila, our classic Margarita strikes all of the right keys."
            };

            var cocktailIngredient = new CocktailIngredients
            {
                CocktailId   = Guid.Parse("9ef97551-87f6-40ce-a88b-6c0e876ccb51"),
                IngredientId = Guid.Parse("4039e0f3-8d2d-43a5-a82b-477e42371cd6"),
                UnlistedOn   = DateTime.UtcNow
            };

            using (var arrangeContext = new CMContext(options))
            {
                arrangeContext.Ingredients.Add(ingredient);
                arrangeContext.Cocktails.Add(cocktail);
                arrangeContext.CocktailIngredients.Add(cocktailIngredient);

                arrangeContext.SaveChanges();
            }

            using (var assertContext = new CMContext(options))
            {
                var sut    = new CocktailService(assertContext);
                var result = await sut.IngredientIsUnlisted
                                 (cocktailIngredient.CocktailId, cocktailIngredient.IngredientId);

                Assert.IsTrue(result);
            }
        }
        public async Task Return_Correct_Updated_Ingredient()
        {
            var options = Utils.GetOptions(nameof(Return_Correct_Updated_Ingredient));

            var ingredient = new Ingredient
            {
                Id          = Guid.Parse("4039e0f3-8d2d-43a5-a82b-477e42371cd6"),
                Name        = "Martini Extra Dry",
                Abv         = 0,
                Description = "",
                TypeId      = Guid.Parse("619ac43c-075a-47be-befc-c68249054b85"),
                Type        = new IngredientType
                {
                    Id   = Guid.Parse("619ac43c-075a-47be-befc-c68249054b85"),
                    Name = "Rum"
                }
            };

            var ingredientType = new IngredientType()
            {
                Id   = Guid.Parse("4a399308-dec0-4161-a679-18b4898c7e4b"),
                Name = "Liqeur"
            };

            using (var arrangeContext = new CMContext(options))
            {
                arrangeContext.Ingredients.Add(ingredient);
                arrangeContext.IngredientTypes.Add(ingredientType);
                arrangeContext.SaveChanges();
            }

            var newName  = "Water";
            var newAbv   = 15;
            var newDescr = "Top";

            using (var assertContext = new CMContext(options))
            {
                var sut    = new IngredientService(assertContext);
                var result = await sut.UpdateIngredient(ingredient.Id, newName, newAbv, newDescr, ingredientType.Id);

                Assert.AreEqual(ingredient.Id, result.Id);
                Assert.AreEqual(newName, result.Name);
                Assert.AreEqual(newDescr, result.Description);
                Assert.AreEqual(newAbv, result.Abv);
                Assert.AreEqual(ingredientType.Id, result.TypeId);
            }
        }
        public void DeletePlaneExecute(object parameter)
        {
            string       message       = "是否确定删除";
            string       detailMessage = string.Format("本操作将会删除楼层:{0},以及该楼层内全部区域和区域内的货物", Plane.PlaneName);
            PromptWindow prompt        = new PromptWindow(message, detailMessage);
            bool?        IsConfirmed   = prompt.ShowDialog();

            if (IsConfirmed == true)
            {
                WarehouseManagementUserControl          wmuc   = parameter as WarehouseManagementUserControl;
                WarehouseManagementUserControlViewModel wmucvm = wmuc.DataContext as WarehouseManagementUserControlViewModel;
                wmucvm.CargoCollectionViewModels = null;
                DeleteCargoCollections();
                CMContext.Plane.Remove(Plane);
                WarehouseViewModel.PlaneViewModels.Remove(this);
                CMContext.SaveChanges();
            }
        }
Example #15
0
        public static void SeedCocktails(CMContext context)
        {
            const string cocktailsJsonAddress = @"../Cocktail_Magician_DB/DataSeeder/JsonFiles/Cocktails.json";

            if (context.Cocktails.Any())
            {
                return;
            }

            var listCocktails = ReadFileDatabase.ReadJsonsSeeds <Cocktail>(cocktailsJsonAddress);

            foreach (var cocktail in listCocktails)
            {
                var cocktailToAdd = new Cocktail
                {
                    Name               = cocktail.Name,
                    Rating             = cocktail.Rating,
                    Picture            = cocktail.Picture,
                    CocktailIngredient = new List <CocktailIngredient>()
                };
                foreach (var item in cocktail.CocktailIngredient)
                {
                    var ingredient = context.Ingredients.SingleOrDefault(i => i.Name == item.Ingredient.Name);
                    if (ingredient != null)
                    {
                        cocktailToAdd.CocktailIngredient.Add(new CocktailIngredient
                        {
                            Cocktail   = cocktailToAdd,
                            Ingredient = ingredient
                        });
                    }
                }
                var cocktailInfo = new List <string>();
                foreach (var item in cocktail.CocktailIngredient)
                {
                    cocktailInfo.Add(item.Ingredient.Name);
                }
                var cocktailRecipe = String.Join(',', cocktailInfo);
                cocktailToAdd.Information = cocktailRecipe;

                context.Cocktails.Add(cocktailToAdd);
                context.SaveChanges();
            }
        }
        public void DeleteBlockExecute(object parameter)
        {
            string       message       = "是否确定删除";
            string       detailMessage = string.Format("本操作将会删除区域:{0},以及该区域内的全部货物", Block.BlockName);
            PromptWindow prompt        = new PromptWindow(message, detailMessage);
            bool?        IsConfirmed   = prompt.ShowDialog();

            if (IsConfirmed == true)
            {
                WarehouseManagementUserControl          wmuc   = parameter as WarehouseManagementUserControl;
                WarehouseManagementUserControlViewModel wmucvm = wmuc.DataContext as WarehouseManagementUserControlViewModel;
                wmucvm.CargoCollectionViewModels = null;
                AllCargoCollectionViewModels     = wmucvm.AllCargoCollectionViewModels;
                DeleteCargoCollections();
                CMContext.Block.Remove(Block);
                PlaneViewModel.BlockViewModels.Remove(this);
                CMContext.SaveChanges();
            }
        }
        public void DeleteExecute(object parameter)
        {
            string       message       = "是否删除该品类";
            string       detailMessage = "删除该品类将会删除所有库存中该品类的商品";
            PromptWindow prompt        = new PromptWindow(message, detailMessage);
            bool?        IsConfirmed   = prompt.ShowDialog();

            if (IsConfirmed == true)
            {
                var p = CargoCollectionViewModels.Where <CargoCollectionViewModel>
                            (item => item.CargoCollection.PreciseCargoName == Cargo.PreciseCargoName).ToList();
                foreach (var i in p)
                {
                    i.DeleteCargoCollection();
                }
                CMContext.Cargo.Remove(Cargo);
                CargoViewModels.Remove(this);
                CMContext.SaveChanges();
            }
        }
Example #18
0
        public static void SeedBars(CMContext context)
        {
            const string barsJsonAddress = @"../Cocktail_Magician_DB/DataSeeder/JsonFiles/Bars.json";

            if (context.Bars.Any())
            {
                return;
            }

            var listBars = ReadFileDatabase.ReadJsonsSeeds <Bar>(barsJsonAddress);

            foreach (var bar in listBars)
            {
                var barToAdd = new Bar()
                {
                    Name          = bar.Name,
                    Address       = bar.Address,
                    Rating        = bar.Rating,
                    Information   = bar.Information,
                    Picture       = bar.Picture,
                    MapDirections = bar.MapDirections,
                    BarCocktails  = new List <BarCocktail>()
                };

                foreach (var item in bar.BarCocktails)
                {
                    var cocktail = context.Cocktails.SingleOrDefault(c => c.Name == item.Cocktail.Name);
                    if (cocktail != null)
                    {
                        barToAdd.BarCocktails.Add(new BarCocktail
                        {
                            Bar      = barToAdd,
                            Cocktail = cocktail
                        });
                    }
                }

                context.Bars.Add(barToAdd);
                context.SaveChanges();
            }
        }
Example #19
0
        public static void SeedIngredients(CMContext context)
        {
            const string ingredientsJsonAddress = @"../Cocktail_Magician_DB/DataSeeder/JsonFiles/Ingredients.json";

            if (context.Ingredients.Any())
            {
                return;
            }

            var listIngredients = ReadFileDatabase.ReadJsonsSeeds <Ingredient>(ingredientsJsonAddress);

            foreach (var ingredient in listIngredients)
            {
                context.Ingredients.Add(new Ingredient()
                {
                    Name = ingredient.Name
                });

                context.SaveChanges();
            }
        }
Example #20
0
        public async Task Return_Correct_Updated_Cocktail()
        {
            var options = Utils.GetOptions(nameof(Return_Correct_Updated_Cocktail));

            var cocktail = new Cocktail()
            {
                Id          = Guid.Parse("9ef97551-87f6-40ce-a88b-6c0e876ccb51"),
                Name        = "Margarita",
                Description = "The Margarita is one of the most " +
                              "popular cocktails in North America—for good reason. " +
                              "Combining the tang of lime and the sweetness of o" +
                              "range liqueur with the distinctive strength of " +
                              "tequila, our classic Margarita strikes all of the right keys."
            };


            using (var arrangeContext = new CMContext(options))
            {
                arrangeContext.Cocktails.Add(cocktail);
                arrangeContext.SaveChanges();
            }

            var newName  = "Water";
            var newDescr = "New";

            using (var assertContext = new CMContext(options))
            {
                var sut = new CocktailService(assertContext);

                var result = await sut.UpdateCocktail(cocktail.Id, newName, newDescr);

                Assert.AreEqual(cocktail.Id, result.Id);
                Assert.AreEqual(newName, result.Name);
                Assert.AreEqual(newDescr, result.Description);
            }
        }
        private void ConfirmSellOrderCollectionExecute(object parameter)
        {
            string       message       = "是否确认订单";
            string       detailMessage = "请检查卖货订单中的每一个条目是否正确,确认订单后将无法修改";
            PromptWindow prompt        = new PromptWindow(message, detailMessage);
            bool?        IsConfirmed   = prompt.ShowDialog();

            if (IsConfirmed == true)
            {
                DateTime CurrentTime = DateTime.Now;
                SellOrderCollectionViewModel.SellOrderCollection.SellTime = CurrentTime;
                foreach (var sellorderviewmodel in SellOrderCollectionViewModel.SellOrderViewModels)
                {
                    sellorderviewmodel.SellOrder.SellTime = CurrentTime;
                    CMContext.SellOrder.Add(sellorderviewmodel.SellOrder);
                    CargoCollectionViewModel cargoCollectionViewModel = sellorderviewmodel.CargoCollectionViewModel;
                    if (cargoCollectionViewModel.CargoCollection.Amount == sellorderviewmodel.SellOrder.Amount)
                    {
                        CMContext.CargoCollection.Remove(cargoCollectionViewModel.CargoCollection);
                        cargoCollectionViewModel.BlockViewModel.CargoCollectionViewModels.Remove(cargoCollectionViewModel);
                        cargoCollectionViewModel.CargoCollectionViewModels.Remove(cargoCollectionViewModel);
                    }
                    else
                    {
                        int BufferAmount = sellorderviewmodel.SellOrder.Amount;
                        cargoCollectionViewModel.CargoCollection.PurchasePrizeDics[0].Amount -= sellorderviewmodel.SellOrder.Amount;
                        cargoCollectionViewModel.CargoCollection.Amount -= sellorderviewmodel.SellOrder.Amount;
                        foreach (var dic in cargoCollectionViewModel.CargoCollection.PurchasePrizeDics)
                        {
                            if (dic.UnitPurchasePrize == -1)
                            {
                                continue;
                            }
                            else if (BufferAmount == 0)
                            {
                                break;
                            }
                            else if (dic.Amount == BufferAmount)
                            {
                                dic.Amount   = 0;
                                BufferAmount = 0;
                            }
                            else if (dic.Amount < BufferAmount)
                            {
                                BufferAmount -= dic.Amount;
                                dic.Amount    = 0;
                            }
                            else if (dic.Amount > BufferAmount)
                            {
                                dic.Amount  -= BufferAmount;
                                BufferAmount = 0;
                            }
                        }
                        var bufferresult = cargoCollectionViewModel.CargoCollection.PurchasePrizeDics.Where <PurchasePrizeDic>(item => item.Amount == 0).ToList();

                        for (int i = 0; i < bufferresult.Count(); i++)
                        {
                            cargoCollectionViewModel.CargoCollection.PurchasePrizeDics.Remove(bufferresult[i]);
                        }
                    }
                }
                CMContext.SellOrderCollection.Add(SellOrderCollectionViewModel.SellOrderCollection);
                SellOrderCollectionViewModels.Add(SellOrderCollectionViewModel);
                CMContext.SaveChanges();
                SellOrderCollectionViewModel = null;
                OutSellOrderButtonIsEnabled  = false;
            }
        }
        public async Task Return_Correct_Number_CocktailIngredients()
        {
            var options = Utils.GetOptions(nameof(Return_Correct_Number_CocktailIngredients));

            var ingredient = new Ingredient
            {
                Id          = Guid.Parse("4039e0f3-8d2d-43a5-a82b-477e42371cd6"),
                Name        = "Martini Extra Dry",
                Abv         = 0,
                Description = "",
                TypeId      = Guid.Parse("619ac43c-075a-47be-befc-c68249054b85"),
            };

            var ingredient2 = new Ingredient()
            {
                Id          = Guid.Parse("1b98e50e-8314-4b1e-82df-491c3c8d086f"),
                Name        = "Gin",
                Abv         = 40,
                Description = "Gin is a distilled alcoholic drink that derives its predominant flavour from juniper berries (Juniperus communis). Gin is one of the broadest categories of spirits, all of various origins, styles, and flavour profiles, that revolve around juniper as a common ingredient.",
                TypeId      = Guid.Parse("24cd3f18-f0a8-4f66-bc5b-2108e099cf53"),
            };

            var cocktail = new Cocktail
            {
                Id          = Guid.Parse("9ef97551-87f6-40ce-a88b-6c0e876ccb51"),
                Name        = "Margarita",
                Description = "The Margarita is one of the most " +
                              "popular cocktails in North America—for good reason. " +
                              "Combining the tang of lime and the sweetness of o" +
                              "range liqueur with the distinctive strength of " +
                              "tequila, our classic Margarita strikes all of the right keys."
            };

            var cocktailIngredient = new CocktailIngredients
            {
                CocktailId   = cocktail.Id,
                IngredientId = ingredient.Id
            };

            var cocktailIngredient2 = new CocktailIngredients
            {
                CocktailId   = cocktail.Id,
                IngredientId = ingredient2.Id
            };

            using (var arrangeContext = new CMContext(options))
            {
                arrangeContext.Ingredients.Add(ingredient);
                arrangeContext.Ingredients.Add(ingredient2);
                arrangeContext.Cocktails.Add(cocktail);
                arrangeContext.CocktailIngredients.Add(cocktailIngredient);
                arrangeContext.CocktailIngredients.Add(cocktailIngredient2);
                arrangeContext.SaveChanges();
            }

            using (var assertContext = new CMContext(options))
            {
                var sut    = new CocktailService(assertContext);
                var result = await sut.GetAllCocktailIngredients();

                Assert.AreEqual(2, result.Count());
            }
        }
 private void DeleteImageExecute(object parameter)
 {
     Cargo.CargoImage = null;
     CMContext.SaveChanges();
 }