コード例 #1
0
        /// <summary>
        /// Add a Zone at Home and return it id.
        /// </summary>
        public int AddZone(string nameZone)
        {
            UnitOfWork repository = UnitOfWork.GetInstance();

            Zone zone = new Zone
            {
                Name = nameZone,
                Home = repository.HomeRespository.GetHome(),
            };

            zone = repository.ZoneRepository.Insert(zone);

            View view = new View
            {
                Name = nameZone,
                Zone = zone
            };

            repository.ViewRepository.Insert(view);

            zone.MainView = view;

            repository.Commit();

            return zone.Id;
        }
コード例 #2
0
        /// <summary>
        /// Add a View in a concrete Zone at Home, return the View's id
        /// </summary>
        public int AddView(int idZone, string nameView)
        {
            UnitOfWork repository = UnitOfWork.GetInstance();

            Zone zone = repository.ZoneRepository.GetById(idZone);

            if (zone == null)
                throw new ArgumentException("Zone id doesn't exist");

            View view = new View()
            {
                Name = nameView,
                Zone = zone,
            };
            view = repository.ViewRepository.Insert(view);

            zone.Views.Add(view);

            repository.Commit();

            return view.Id;
        }