public void RemoveRelationShips(BinsInSubRoute bir)
        {
            bir.Subroute.BinsInSubRoutes.Remove(bir);
            bir.Bin.BinsInSubRoutes.Remove(bir);

            bir.Subroute = null;
            bir.Bin      = null;
        }
 public void CreateBinInSubroute(BinsInSubRoute bir)
 {
     using (ConfigurationToolContext context = new ConfigurationToolContext())
     {
         var repository = new BinsInSubrouteRepository(context);
         repository.Add(bir);
         context.SaveChanges();
     }
 }
        public void AddRelationShips(BinsInSubRoute bir, Subroute subroute, Bin bin)
        {
            //add references to BinInSubroute
            bir.Bin      = bin;
            bir.Subroute = subroute;

            //Add references to Bin and subroute
            subroute.BinsInSubRoutes.Add(bir);
            bin.BinsInSubRoutes.Add(bir);
        }
示例#4
0
        private void AddDestinationBin()
        {
            BinsInSubrouteService service = new BinsInSubrouteService();

            foreach (Bin B in SelectedBins)
            {
                //generate new binsinsubroute
                BinsInSubRoute bir = service.GenerateBinsInSubroute(Subroute, B, SourceDest.D);

                //if it already exists continue
                if (DestinationBins.Any(item => item.bir_BinId == bir.bir_BinId))
                {
                    continue;
                }

                //create new database entry
                service.CreateBinInSubroute(bir);

                //connect relationships
                service.AddRelationShips(bir, Subroute, B);
            }
            GetSourceDestinationLists();
        }