Example #1
0
        public HttpResponseMessage GetAreasByCityID(int cityId)
        {
            ResultMsg resultMsg = new ResultMsg();

            try
            {
                string cityCode = string.Empty;
                using (ICity repository = new CityRepository())
                {
                    cityCode = repository.Find(cityId).CityCode;
                }
                using (IArea repository = new AreaRepository())
                {
                    var list = repository.FindAll(o => o.CityCode == cityCode);
                    resultMsg.code = 0;
                    resultMsg.data = list;
                }
            }
            catch (Exception ex)
            {
                resultMsg.code = (int)StatusCodeEnum.Error;
                resultMsg.msg  = ex.Message;
            }
            return(resultMsg.toJson());
        }
Example #2
0
        public ActionResult Index(AreaView av)
        {
            try
            {
                string nombreArea = Request.Form["txtNombreArea"];

                AreaRepository pr    = new AreaRepository();
                List <Area>    Areas = pr.Listar(nombreArea);

                av.Area        = new Area();
                av.Area.Nombre = nombreArea;
                av.Areas       = Areas;

                string mensaje = "";
                if (Areas.Count == 0)
                {
                    mensaje = "No existen Areas para el criterio de búsqueda";
                }
                av.Mensaje = mensaje;

                return(View(av));
            }
            catch (Exception ex)
            {
                return(View("Mensaje", new AreaView {
                    Mensaje = ex.Message
                }));
            }
        }
Example #3
0
        public object GetWareArea()
        {
            var            warehouses = WarehouseRepository.GetQueryable().AsEnumerable();
            HashSet <Tree> wareSet    = new HashSet <Tree>();

            foreach (var warehouse in warehouses)//仓库
            {
                Tree wareTree = new Tree();
                wareTree.id         = warehouse.WarehouseCode;
                wareTree.text       = "仓库:" + warehouse.WarehouseName;
                wareTree.state      = "open";
                wareTree.attributes = "ware";

                var areas = AreaRepository.GetQueryable().Where(a => a.Warehouse.WarehouseCode == warehouse.WarehouseCode)
                            .OrderBy(a => a.AreaCode).Select(a => a);
                HashSet <Tree> areaSet = new HashSet <Tree>();
                foreach (var area in areas)//库区
                {
                    Tree areaTree = new Tree();
                    areaTree.id         = area.AreaCode;
                    areaTree.text       = "库区:" + area.AreaName;
                    areaTree.state      = "open";
                    areaTree.attributes = "area";
                    areaSet.Add(areaTree);
                }
                wareTree.children = areaSet.ToArray();
                wareSet.Add(wareTree);
            }
            return(wareSet.ToArray());
        }
Example #4
0
        /// <summary>Loads this instance.</summary>
        public void Load()
        {
            var areaRepository = new AreaRepository();

            // @@@ TODO: Fix hack: http://www.wheelmud.net/tabid/59/aft/1622/Default.aspx
            string areaNumber              = this.Parent.ID.Replace("area/", string.Empty);
            long   persistedAreaID         = long.Parse(areaNumber);
            ICollection <RoomRecord> rooms = areaRepository.GetRoomsForArea(persistedAreaID);

            foreach (var roomRecord in rooms)
            {
                // @@@ TODO: Fix hack: http://www.wheelmud.net/tabid/59/aft/1622/Default.aspx
                var roomBehavior = new RoomBehavior()
                {
                    ID = roomRecord.ID,
                };
                var currRoom = new Thing(roomBehavior)
                {
                    Name        = roomRecord.Name,
                    Description = roomRecord.Description,
                    ID          = "room/" + roomRecord.ID,
                };

                // Load this room and it's children.
                roomBehavior.Load();
                this.Parent.Add(currRoom);
            }
        }
Example #5
0
        /// <summary>
        /// 根据仓库编码获取生成的库区编码
        /// </summary>
        /// <param name="wareCode">仓库编码</param>
        /// <returns></returns>
        public object GetAreaCode(string wareCode)
        {
            string            areaCodeStr = "";
            IQueryable <Area> areaQuery   = AreaRepository.GetQueryable();
            var areaCode = areaQuery.Where(a => a.WarehouseCode == wareCode).Max(a => a.AreaCode);

            if (areaCode == string.Empty || areaCode == null)
            {
                areaCodeStr = wareCode + "-01";
            }
            else
            {
                int i = Convert.ToInt32(areaCode.ToString().Substring(wareCode.Length, 2));
                i++;
                string newcode = i.ToString();
                if (newcode.Length <= 2)
                {
                    for (int j = 0; j < 2 - i.ToString().Length; j++)
                    {
                        newcode = "0" + newcode;
                    }
                    areaCodeStr = wareCode + "-" + newcode;
                }
            }
            return(areaCodeStr);
        }
Example #6
0
        /// <summary>
        /// 查询参数Code查询库区信息
        /// </summary>
        /// <param name="areaCode">库区Code</param>
        /// <returns></returns>
        public object FindArea(string areaCode)
        {
            IQueryable <Area> areaQuery = AreaRepository.GetQueryable();
            var area = areaQuery.Where(a => a.AreaCode == areaCode).OrderBy(b => b.AreaCode).AsEnumerable().Select(b => new { b.AreaCode, b.AreaName, b.AreaType, b.ShortName, b.AllotInOrder, b.AllotOutOrder, b.Description, b.Warehouse.WarehouseCode, b.Warehouse.WarehouseName, IsActive = b.IsActive == "1" ? "可用" : "不可用", UpdateTime = b.UpdateTime.ToString("yyyy-MM-dd hh:mm:ss") });

            return(area.First(a => a.AreaCode == areaCode));
        }
        public void TestAreaGet2()
        {
            var id = Guid.NewGuid();

            IMMRequestContext IMMRequestContext = ContextFactory.GetNewContext();
            AreaRepository    areaRepo          = new AreaRepository(IMMRequestContext);

            Area area1 = new Area()
            {
                Id     = id,
                Name   = "Limpieza",
                Topics = new List <Topic>()
            };

            Area area2 = new Area()
            {
                Id     = Guid.NewGuid(),
                Name   = "Transporte",
                Topics = new List <Topic>()
            };

            areaRepo.Add(area1);
            areaRepo.Add(area2);
            areaRepo.Save();

            Assert.AreEqual(areaRepo.Get(id), area1);
        }
        public void TestAreaGetAllOK2()
        {
            IMMRequestContext IMMRequestContext = ContextFactory.GetNewContext();
            AreaRepository    areaRepo          = new AreaRepository(IMMRequestContext);

            areaRepo.Add(new Area
            {
                Id     = Guid.NewGuid(),
                Name   = "Limpieza",
                Topics = new List <Topic>()
            });

            areaRepo.Add(new Area
            {
                Id     = Guid.NewGuid(),
                Name   = "Transporte",
                Topics = new List <Topic>()
            });

            areaRepo.Save();

            var areas = areaRepo.GetAll().ToList().Count();

            Assert.AreEqual(2, areas);
        }
Example #9
0
 public LoadService(IpGeoBaseContext dataContext)
 {
     DataContext = dataContext;
     AreaRepository = new AreaRepository(dataContext);
     RegionRepository = new RegionRepository(dataContext);
     LocationRepository = new LocationRepository(dataContext);
     RangeRepository = new RangeRepository(dataContext);
 }
Example #10
0
        public OperationResult Delete(int Id)
        {
            var model = Areas.FirstOrDefault(t => t.Id == Id);

            model.IsDeleted = true;
            AreaRepository.Update(model);
            return(new OperationResult(OperationResultType.Success, "删除成功"));
        }
Example #11
0
 public LoadService(IpGeoBaseContext dataContext)
 {
     DataContext        = dataContext;
     AreaRepository     = new AreaRepository(dataContext);
     RegionRepository   = new RegionRepository(dataContext);
     LocationRepository = new LocationRepository(dataContext);
     RangeRepository    = new RangeRepository(dataContext);
 }
Example #12
0
        private void LoadLists()
        {
            m_partModels     = PartRepository.GetAllPartModels(UnitOfWork);
            m_shopfloorlines = AreaRepository.GetAllShopfloorlines(UnitOfWork);

            m_routeStations = Scout.Core.Service <IShopfloorService>()
                              .GetAllRouteStations(UnitOfWork);
        }
Example #13
0
 public DapperTest()
 {
     _areaRepository = DRepository.Instance <AreaRepository>();
     Mapper.Initialize(cfg =>
     {
         cfg.CreateMissingTypeMaps = true;
     });
 }
Example #14
0
        public ActionResult Registration()
        {
            AreaRepository _repo = new AreaRepository();

            ViewBag.ARE_DES_NAME = new SelectList(_repo.GetAll2(), "ARE_IDE_AREA", "ARE_DES_NAME", "ARE_IDE_AREA");
            //ViewBag.ListadoAreas = _repo.GetAll2();
            return(View());
        }
Example #15
0
        public List <Area> GetListArea()
        {
            List <Area>    list = new List <Area>();
            AreaRepository area = new AreaRepository();

            list = area.GetAllArea().ToList();
            return(list);
        }
Example #16
0
        public List <Project> GetProjects()
        {
            var projectsWithAreas = from p in ProjectRepository.All()
                                    join a in AreaRepository.All() on p.ProjectId equals a.ProjectId
                                    select p;

            return(projectsWithAreas.ToList());
        }
 public PreguntaController(ILogger <PreguntaController> logger, IMapper mapper)
 {
     _mapper              = mapper;
     _logger              = logger;
     _preguntaRepository  = new PreguntaRepository();
     _sesionRepository    = new SesionRepository();
     _respuestaRepository = new RespuestaRepository();
     _areaRepository      = new AreaRepository();
 }
Example #18
0
 public UnitOfWork(ApplicationDbContext context)
 {
     _context         = context;
     Areas            = new AreaRepository(_context);
     Regions          = new RegionRepository(_context);
     Districts        = new DistrictRepository(_context);
     Stores           = new StoreRepository(_context);
     CorporateOffices = new CorporateOfficeRepository(_context);
 }
        public void GetInvalid()
        {
            var id = Guid.NewGuid();

            IMMRequestContext IMMRequestContext = ContextFactory.GetNewContext();
            AreaRepository    areaRepo          = new AreaRepository(IMMRequestContext);

            areaRepo.Get(id);
        }
Example #20
0
        public ModelResult GetChildAreas(AreaRequest request)
        {
            var list = AreaRepository.GetAreasByParentID(request.ParentID);

            return(new ModelResult
            {
                Data = list.Select(x => new { ID = x.ID, Name = x.Name }).ToList()
            });
        }
Example #21
0
 public UnitOfWork(AppDbContext context)
 {
     _context                     = context;
     RestaurantRepository         = new RestaurantRepository(context);
     MealCategoryRepository       = new MealCategoryRepository(context);
     MealTypeRepository           = new MealTypeRepository(context);
     MealRepository               = new MealRepository(context);
     RestaurantCategoryRepository = new RestaurantCategoryRepository(context);
     AreaRepository               = new AreaRepository(context);
 }
Example #22
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!Page.IsPostBack)
     {
         var repo = new AreaRepository();
         gridArea.DataSource = repo.GetAllByOrder();
         gridArea.DataBind();
         Session["Result"] = gridArea.DataSource;
     }
 }
Example #23
0
        string LoopArea(int sn)
        {
            var obj = AreaRepository.Find(o => o.AreaID == sn);

            if (obj != null)
            {
                return(LoopArea(obj.AreaPID) + "/" + obj.Title);
            }
            return("");
        }
Example #24
0
        public Area GetOne(object id)
        {
            var obj = AreaRepository.Get(id);

            if (obj.AreaPID > 0)
            {
                obj.PTitle = LoopArea(obj.AreaPID).TrimStart('/');
            }
            return(obj);
        }
        public void UpdateInvalid()
        {
            IMMRequestContext IMMRequestContext = ContextFactory.GetNewContext();
            AreaRepository    baseRepo          = new AreaRepository(IMMRequestContext);

            Area InitEntity = CreateEntity();

            baseRepo.Update(InitEntity);
            baseRepo.Save();
        }
Example #26
0
 protected override void OnModelCreating(ModelBuilder modelBuilder)
 {
     modelBuilder.Entity <Area>().HasData(AreaRepository.getAreas());
     modelBuilder.Entity <ServiceInfo>().HasData(ServiceInfoRepository.getSerivecesInfo());
     modelBuilder.Entity <ServiceSoftware>().HasData(ServiceSoftwareRepository.getSerivecesSoftware());
     modelBuilder.Entity <ServiceHardware>().HasData(ServiceHardwareRepository.getSerivecesHardware());
     modelBuilder.Entity <Person>().HasData(PersonRepository.GetPeople());
     modelBuilder.Entity <Organization>().HasData(OrganizationRepository.GetOrganizations());
     modelBuilder.Entity <Contract>().HasData(ContractRepository.GetContracts());
 }
Example #27
0
        public IEnumerable <AreaDTO> GetAreasByProject(int projectId)
        {
            var areas = AreaRepository.Where(a => a.ProjectId == projectId);
            var query = (from a in areas
                         select new AreaDTO()
            {
                AreaId = a.AreaId, Name = a.Name
            }).ToList();

            return(query);
        }
Example #28
0
        /// <summary>
        /// Находит географический округ с указанным названием
        /// </summary>
        /// <param name="areaName">Название географического округа</param>
        /// <returns></returns>
        private Area FindArea(string areaName)
        {
            Area area = AreaRepository.FindByName(areaName);

            if (area == null)
            {
                throw new ArgumentException("Не найден географический округ с указанным названием", "areaName");
            }

            return(area);
        }
 public ResultadoController(ILogger <PreguntaController> logger, IMapper mapper)
 {
     _logger = logger;
     _mapper = mapper;
     _habilidadRepository = new HabilidadRepository();
     _carreraRepository   = new CarreraRepository();
     _areaRepository      = new AreaRepository();
     _resultadoRepository = new ResultadoRepository();
     _sesionRepository    = new SesionRepository();
     _personaRepository   = new PersonaRepository();
 }
Example #30
0
        public List <Area> GetList()
        {
            var list = DataCache.Get <List <Area> >("areas");

            if (list == null)
            {
                list = AreaRepository.GetQuery().OrderBy(o => o.OrderNum).ToList();
                DataCache.Set("areas", list, 20);
            }
            return(list);
        }
Example #31
0
        public OperationResult Update(AreaModel model)
        {
            var entity = Areas.First(t => t.Id == model.Id);

            entity.Name        = model.Name;
            entity.Description = model.Description;
            entity.ParentId    = model.ParentId;

            AreaRepository.Update(entity);
            return(new OperationResult(OperationResultType.Success, "更新成功"));
        }
Example #32
0
 public TargetService(IpGeoBaseContext dataContext)
 {
     DataContext = dataContext;
     TargetRepository = new TargetRepository(dataContext);
     CountryRuleRepository = new CountryRuleRepository(dataContext);
     AreaRuleRepository = new AreaRuleRepository(dataContext);
     AreaRepository = new AreaRepository(dataContext);
     RegionRuleRepository = new RegionRuleRepository(dataContext);
     RegionRepository = new RegionRepository(dataContext);
     LocationRuleRepository = new LocationRuleRepository(dataContext);
     LocationRepository = new LocationRepository(dataContext);
 }
Example #33
0
        public void CanCreateAreaAndAppliance()
        {
            IRepository<Area> repoA = new AreaRepository();
            Area area = new Area();
            area.Name = "PruebaArea";
            area.Description = "Prueba descriptiva area";

            IRepository<Appliance> repoB = new ApplianceRepository();
            Appliance appliance = new Appliance();
            appliance.NameAppliance = "PruebaAppliance";
            appliance.Description = "Prueba descriptiva appliance";
            appliance.Area = area;

            area.Appliances.Add(appliance);

            repoA.Save(area);
        }
Example #34
0
        public void CanCreateSignalWithTolerance()
        {
            IRepository<Area> repoT = new AreaRepository();
            Area area = new Area();
            area = repoT.GetById(1);

            IRepository<Signal> repoA = new SignalRepository();
            Signal signal = new Signal();
            signal.Name = "PruebaSenal";
            signal.Description = "Prueba descriptiva senal";

            repoA.Save(signal);

            IRepository<Appliance> repoB = new ApplianceRepository();
            Appliance appliance = new Appliance();
            appliance.NameAppliance = "PruebaAppliance";
            appliance.Description = "Prueba descriptiva appliance";
            appliance.Area = area;

            IRepository<SignalAppliance> repoC = new SignalApplianceRepository();
            SignalAppliance signalAppliance = new SignalAppliance();
            signalAppliance.Signal = signal;
            signalAppliance.Appliance = appliance;
            signalAppliance.Tolerance = SIGNAL_APPLIANCE_TOLERANCE;

            appliance.Signals.Add(signalAppliance);

            repoB.Save(appliance);

            SignalAppliance createdSignalAppliance = repoC.GetById(signalAppliance.Id);

            Assert.IsNotNull(createdSignalAppliance);

            Assert.AreEqual(signalAppliance, createdSignalAppliance);

            repoC.Delete(signalAppliance.Id);

            repoB.Delete(appliance.Id);

            repoA.Delete(signal.Id);
        }
Example #35
0
        public void CanCreateSignalApplianceAndValues()
        {
            IRepository<Area> repoT = new AreaRepository();
            Area area = new Area();
            area = repoT.GetById(1);
            IRepository<AlarmType> repoAT = new AlarmTypeRepository();
            AlarmType alarm = new AlarmType();
            alarm = repoAT.GetById(1);

            IRepository<Signal> repoA = new SignalRepository();
            Signal signal = new Signal();
            signal.Name = "PruebaSenal";
            signal.Description = "Prueba descriptiva senal";

            repoA.Save(signal);

            IRepository<Appliance> repoB = new ApplianceRepository();
            Appliance appliance = new Appliance();
            appliance.NameAppliance = "PruebaAppliance";
            appliance.Description = "Prueba descriptiva appliance";
            appliance.Area = area;

            SignalAppliance signalAppliance = new SignalAppliance();
            signalAppliance.Signal = signal;
            signalAppliance.Appliance = appliance;

            appliance.Signals.Add(signalAppliance);

            repoB.Save(appliance);

            IRepository<SignalApplianceValue> repoSAV = new SignalApplianceValueRepository();
            SignalApplianceValue signalApplianceValue = new SignalApplianceValue();
            signalApplianceValue.Value = 40;
            signalApplianceValue.SignalAppliance = signalAppliance;
            signalApplianceValue.AlarmType = alarm;

            repoSAV.Save(signalApplianceValue);
        }
Example #36
0
 public void UpsertInDatabase(GameObjectBase gameObject, string connectionString = "")
 {
     if (gameObject.GameObjectType == GameObjectTypeEnum.Area)
     {
         using (AreaRepository repo = new AreaRepository(connectionString))
         {
             repo.Upsert(gameObject as Area);
         }
     }
     else if (gameObject.GameObjectType == GameObjectTypeEnum.Conversation)
     {
         using (ConversationRepository repo = new ConversationRepository(connectionString))
         {
             repo.Upsert(gameObject as Conversation);
         }
     }
     else if (gameObject.GameObjectType == GameObjectTypeEnum.Creature)
     {
         using (CreatureRepository repo = new CreatureRepository(connectionString))
         {
             repo.Upsert(gameObject as Creature);
         }
     }
     else if (gameObject.GameObjectType == GameObjectTypeEnum.Item)
     {
         using (ItemRepository repo = new ItemRepository(connectionString))
         {
             repo.Upsert(gameObject as Item);
         }
     }
     else if (gameObject.GameObjectType == GameObjectTypeEnum.Placeable)
     {
         using (PlaceableRepository repo = new PlaceableRepository(connectionString))
         {
             repo.Upsert(gameObject as Placeable);
         }
     }
     else if (gameObject.GameObjectType == GameObjectTypeEnum.Script)
     {
         using (ScriptRepository repo = new ScriptRepository(connectionString))
         {
             repo.Upsert(gameObject as Script);
         }
     }
     else if (gameObject.GameObjectType == GameObjectTypeEnum.Tileset)
     {
         using (TilesetRepository repo = new TilesetRepository(connectionString))
         {
             repo.Upsert(gameObject as Tileset);
         }
     }
     else
     {
         throw new NotSupportedException();
     }
 }
Example #37
0
 public GameObjectBase GetFromDatabaseByID(int resourceID, GameObjectTypeEnum gameResourceType)
 {
     if (gameResourceType == GameObjectTypeEnum.Area)
     {
         using (AreaRepository repo = new AreaRepository())
         {
             return repo.GetByID(resourceID);
         }
     }
     else if (gameResourceType == GameObjectTypeEnum.Conversation)
     {
         using (ConversationRepository repo = new ConversationRepository())
         {
             return repo.GetByID(resourceID);
         }
     }
     else if (gameResourceType == GameObjectTypeEnum.Creature)
     {
         using (CreatureRepository repo = new CreatureRepository())
         {
             return repo.GetByID(resourceID);
         }
     }
     else if (gameResourceType == GameObjectTypeEnum.Item)
     {
         using (ItemRepository repo = new ItemRepository())
         {
             return repo.GetByID(resourceID);
         }
     }
     else if (gameResourceType == GameObjectTypeEnum.Placeable)
     {
         using (PlaceableRepository repo = new PlaceableRepository())
         {
             return repo.GetByID(resourceID);
         }
     }
     else if (gameResourceType == GameObjectTypeEnum.Script)
     {
         using (ScriptRepository repo = new ScriptRepository())
         {
             return repo.GetByID(resourceID);
         }
     }
     else if (gameResourceType == GameObjectTypeEnum.Tileset)
     {
         using (TilesetRepository repo = new TilesetRepository())
         {
             return repo.GetByID(resourceID);
         }
     }
     else
     {
         throw new NotSupportedException();
     }
 }
Example #38
0
        /// <summary>
        /// Returns all objects from the database that have a matching resource category.
        /// </summary>
        /// <param name="resourceCategory">The resource category all return values must match</param>
        /// <param name="resourceType">The type of resource to look for.</param>
        /// <param name="connectionString">If you need to connect to a specific database, use this to pass the connection string. Otherwise, the default connection string will be used (WinterConnectionInformation.ActiveConnectionString)</param>
        /// <returns></returns>
        public List<GameObjectBase> GetAllFromDatabaseByResourceCategory(Category resourceCategory, GameObjectTypeEnum resourceType, string connectionString = "")
        {
            List<GameObjectBase> retList = new List<GameObjectBase>();

            if (resourceType == GameObjectTypeEnum.Area)
            {
                using (AreaRepository repo = new AreaRepository(connectionString))
                {
                    return repo.GetAllByResourceCategory(resourceCategory).ConvertAll(x => (GameObjectBase)x);
                }
            }
            else if (resourceType == GameObjectTypeEnum.Conversation)
            {
                using (ConversationRepository repo = new ConversationRepository(connectionString))
                {
                    return repo.GetAllByResourceCategory(resourceCategory).ConvertAll(x => (GameObjectBase)x);
                }
            }
            else if (resourceType == GameObjectTypeEnum.Creature)
            {
                using (CreatureRepository repo = new CreatureRepository(connectionString))
                {
                    return repo.GetAllByResourceCategory(resourceCategory).ConvertAll(x => (GameObjectBase)x);
                }
            }
            else if (resourceType == GameObjectTypeEnum.Item)
            {
                using (ItemRepository repo = new ItemRepository(connectionString))
                {
                    return repo.GetAllByResourceCategory(resourceCategory).ConvertAll(x => (GameObjectBase)x);
                }
            }
            else if (resourceType == GameObjectTypeEnum.Placeable)
            {
                using (PlaceableRepository repo = new PlaceableRepository(connectionString))
                {
                    return repo.GetAllByResourceCategory(resourceCategory).ConvertAll(x => (GameObjectBase)x);
                }
            }
            else if (resourceType == GameObjectTypeEnum.Script)
            {
                using (ScriptRepository repo = new ScriptRepository(connectionString))
                {
                    return repo.GetAllByResourceCategory(resourceCategory).ConvertAll(x => (GameObjectBase)x);
                }
            }
            else if (resourceType == GameObjectTypeEnum.Tileset)
            {
                using (TilesetRepository repo = new TilesetRepository(connectionString))
                {
                    return repo.GetAllByResourceCategory(resourceCategory).ConvertAll(x => (GameObjectBase)x);
                }
            }
            else
            {
                throw new NotSupportedException();
            }
        }
Example #39
0
 /// <summary>
 /// Returns True if an object exists in the database.
 /// Returns False if an object does not exist in the database.
 /// </summary>
 /// <param name="resref">The resource reference to search for.</param>
 /// <param name="resourceType">The resource type to look for.</param>
 /// <param name="connectionString">If you need to connect to a specific database, use this to pass the connection string. Otherwise, the default connection string will be used (WinterConnectionInformation.ActiveConnectionString)</param>
 /// <returns></returns>
 public bool DoesObjectExistInDatabase(string resref, GameObjectTypeEnum resourceType, string connectionString = "")
 {
     if (resourceType == GameObjectTypeEnum.Area)
     {
         using (AreaRepository repo = new AreaRepository(connectionString))
         {
             return repo.Exists(resref);
         }
     }
     else if (resourceType == GameObjectTypeEnum.Conversation)
     {
         using (ConversationRepository repo = new ConversationRepository(connectionString))
         {
             return repo.Exists(resref);
         }
     }
     else if (resourceType == GameObjectTypeEnum.Creature)
     {
         using (CreatureRepository repo = new CreatureRepository(connectionString))
         {
             return repo.Exists(resref);
         }
     }
     else if (resourceType == GameObjectTypeEnum.Item)
     {
         using (ItemRepository repo = new ItemRepository(connectionString))
         {
             return repo.Exists(resref);
         }
     }
     else if (resourceType == GameObjectTypeEnum.Placeable)
     {
         using (PlaceableRepository repo = new PlaceableRepository(connectionString))
         {
             return repo.Exists(resref);
         }
     }
     else if (resourceType == GameObjectTypeEnum.Script)
     {
         using (ScriptRepository repo = new ScriptRepository(connectionString))
         {
             return repo.Exists(resref);
         }
     }
     else if (resourceType == GameObjectTypeEnum.Tileset)
     {
         using (TilesetRepository repo = new TilesetRepository(connectionString))
         {
             return repo.Exists(resref);
         }
     }
     else
     {
         throw new NotSupportedException();
     }
 }
Example #40
0
        /// <summary>
        /// Select feed posts relevant to the users current geo-context
        /// </summary>
        public List<PostRendered> GetGeoFeed(double lat, double lon, PostType postType, ClientAppType clientType)
        {
            var intersectingAreas = new AreaRepository().GetIntersectingAreasOfPoint(lat, lon).ToList();
            var feedPlaces = GetGeoDeducPlaces(intersectingAreas.Select(p => p.ID));

            if (feedPlaces.Count < 2) { feedPlaces.AddRange(from p in new MobileSvcRepository().GetNearestLocationsV0(lat, lon, 4) select CfCacheIndex.Get(p.ID)); }

            return GetPostsForPlaces(feedPlaces, postType, clientType);
        }
        private void CreatePartnerCallAuthorization(PartnerCall obj)
        {
            var place = CfCacheIndex.Get(obj.PlaceID);

            if (place.Type == CfType.Country || place.Type == CfType.Province)
            {
                throw new Exception("You can not post for a country or a province as this will cause too many people to receive an alert about your partner call.");
            }
            if (place.Type == CfType.ClimbingArea)
            {
                var area = new AreaRepository().GetByID(place.ID);
                if (area.DisallowPartnerCalls)
                {
                    throw new Exception("You can not post for "+area.Name+" as it has been disallowed by admin probably because it will too many people to receive an alert about your partner call. Please choose a smaller related area.");
                }
            }

            ////-- Check user isn't submitting multiple within 1 hour
            var usersMostRecentCalls = GetUsersLatestPartnerCalls(CfIdentity.UserID, 3).ToList();
            var similarInLastHour = usersMostRecentCalls.Where(pc => pc.ID == obj.ID && pc.CreatedUtc > DateTime.UtcNow.AddHours(-1));
            if (similarInLastHour.Count() > 0) { throw new Exception("You can only post once every hour for the same place other wise you will cause too many people to receive alerts about your calls."); }

            if (!obj.ForIndoor && !obj.ForOutdoor) { throw new ArgumentOutOfRangeException("Cannot create a partner call with neither indoor or outdoor climbing specified"); }
            if (obj.StartDateTime < DateTime.Now.AddDays(-1)) { throw new ArgumentOutOfRangeException("Cannot create a partner call with the start date " + obj.StartDateTime + " as it is in the past"); }
        }
Example #42
0
        public void ListMonitoringRecordsForInbox()
        {
            IRepository<SignalAppliance> dbSA = new SignalApplianceRepository();
            IRepository<MappingTag> dbMapT = new MappingTagRepository();
            IRepository<Monitoring> dbMon = new MonitoringRepository();
            IRepository<Signal> dbS = new SignalRepository();
            IRepository<Appliance> dbApp = new ApplianceRepository();
            IRepository<SignalApplianceValue> dbSAppV = new SignalApplianceValueRepository();
            IRepository<AlarmType> dbAT = new AlarmTypeRepository();
            IRepository<Area> dbA = new AreaRepository();

            var monRecords = from r in (
                                          from mon in dbMon.GetAll()
                                          join mapp in dbMapT.GetAll() on mon.MappingTag.Id equals mapp.Id
                                        select new { monDatetime = mon.DateTime, appId = mapp.Appliance.Id, sigId = mapp.Signal.Id, pv =  (mapp.AlarmType.Id.Equals(Convert.ToInt32("1")) ? mon.Value: 0 ), alarm = (mon.Value == 1 && !mapp.AlarmType.Id.Equals(Convert.ToInt32("1")) ? mapp.AlarmType.Id : 0 ) ,userId = mon.User.Id})
                            group r by new {r.monDatetime, r.appId, r.sigId, r.userId} into g
                           select new { monRecord = g.Key, monValue = g.Sum(d => d.pv), alarm = g.Sum(d => d.alarm) };

            var result = from m in monRecords
                         join mon in dbMon.GetAll() on m.monRecord.monDatetime equals mon.DateTime
                         join mapp in dbMapT.GetAll() on new { mapId = mon.MappingTag.Id, appId = m.monRecord.appId, sigId = m.monRecord.sigId } equals new { mapId = mapp.Id, appId = mapp.Appliance.Id, sigId = mapp.Signal.Id }
                         where (m.alarm == 0 ? 1 : m.alarm) == mapp.AlarmType.Id
                         select new { monId = mon.Id, dateTime = m.monRecord.monDatetime, appId = m.monRecord.appId, sigId = m.monRecord.sigId, alarm = m.alarm, monValue = m.monValue, userId = m.monRecord.userId };

            /*
                to_char(tmp.datetime, 'yyyy/mm/dd hh24:mi:ss') mon_datetime, area.are_name, sig.sig_name,
                decode(tmp.alarm, 'A', 'Alta', 'B', 'Baja', 'N', 'Normal', 'Desconodido') ala_typ_name,
                smcl_get_appl_signal_comment(tmp.datetime, tmp.app_id, tmp.sig_id, tmp.alarm) mon_comment_on_alarm,
                appl.app_name, case when tmp.sig_id = 1 then round_half_way_down(trunc(tmp.mon_value, 3), 2) else round_half_way_down(trunc(tmp.mon_value, 2), 1) end mon_value ,
                tmp.sig_id, usr.usr_first_name || ' ' || usr.usr_last_name_1 || '(' || usr.usr_login_email || ')' username,
             */
            //group new {a.Id, a.NameAlarmType, sapv.Value } by new {sa.Id, app.NameAppliance, s.Name, sa.Tolerance} into g
            //select new { signalAppliance = g.Key, setPoint = from v in g where v.Id == 1 select v.Value, highValue = from v in g where v.Id == 2 select v.Value, lowValue = from v in g where v.Id == 3 select v.Value };

            ObjectDumper.Write(result.Count());

            foreach (var v in result)
            {
                ObjectDumper.Write(v);
            }
        }
        public ActionResult DeleteConfirmed(int id)
        {
            List<Object> logList = new List<Object>();
            ViewData["ValidationErrorMessage"] = String.Empty;

            Appliance appliance = db.GetById(id);

            try
            {
                IRepository<Area> dbA = new AreaRepository();

                if (appliance != null)
                {
                    db.Delete(id);
                    logList.Add(log.GetNewLog(ConfigurationManager.AppSettings["DeleteText"] +
                                              ControllerContext.RouteData.Values["controller"] +
                                              "(Id=" + appliance.Id.ToString().Replace("-", "").ToUpper() +
                                              " - Description=" + appliance.Description +
                                              " - ApplianceName=" + appliance.NameAppliance +
                                              " - AreaName=" + dbA.GetById(appliance.Area.Id).Name + ")",
                                              (int)EventTypes.Delete,
                                              (int)Session["UserId"]));
                    log.Write(logList);
                }
            }
            catch (GenericADOException)
            {
                ViewData["ValidationErrorMessage"] = ConfigurationManager.AppSettings["CannotDeleteHasAssociatedRecords"];

                logList.Add(log.GetNewLog(ConfigurationManager.AppSettings["DeleteText"] +
                                          ConfigurationManager.AppSettings["CannotDeleteHasAssociatedRecords"] + " " +
                                          ControllerContext.RouteData.Values["controller"] +
                                          "(Id=" + appliance.Id.ToString().Replace("-", "").ToUpper() +
                                          " - Description=" + appliance.Description +
                                          " - ApplianceName=" + appliance.NameAppliance +
                                          " - AreaName=" + dbA.GetById(appliance.Area.Id).Name + ")",
                                          (int)EventTypes.Delete,
                                          (int)Session["UserId"]));
                log.Write(logList);

                Appliance entity = db.GetById(id);
                entity.Area = dbA.GetById(entity.Area.Id);

                return View(entity);
            }
            catch (Exception ex)
            {
                ViewData["ValidationErrorMessage"] = ConfigurationManager.AppSettings["UnknownError"];

                logList.Add(log.GetNewLog(ConfigurationManager.AppSettings["DeleteText"] + ex.InnerException.Message, (int)EventTypes.Delete, (int)Session["UserId"]));
                log.Write(logList);

                return View();
            }

            return RedirectToAction("Index");
        }
Example #44
0
 private void SaveArea(object sender, GameObjectSaveEventArgs e)
 {
     using (AreaRepository repo = new AreaRepository())
     {
         repo.Upsert(e.ActiveArea);
     }
 }
Example #45
0
        /// <summary>
        /// Adds a game object to the database.
        /// </summary>
        /// <param name="gameObject">The game object to add to the database. This will be type-converted and added to the correct table when run.</param>
        /// <param name="connectionString">If you need to connect to a specific database, use this to pass the connection string. Otherwise, the default connection string will be used (WinterConnectionInformation.ActiveConnectionString)</param>
        public GameObjectBase AddToDatabase(GameObjectBase gameObject, string connectionString = "")
        {
            GameObjectBase resultGameObject;
            try
            {
                if (gameObject.GameObjectType == GameObjectTypeEnum.Area)
                {
                    using (AreaRepository repo = new AreaRepository(connectionString))
                    {
                        resultGameObject = repo.Add(gameObject as Area);
                    }
                }
                else if (gameObject.GameObjectType == GameObjectTypeEnum.Conversation)
                {
                    using (ConversationRepository repo = new ConversationRepository())
                    {
                        resultGameObject = repo.Add(gameObject as Conversation);
                    }
                }
                else if (gameObject.GameObjectType == GameObjectTypeEnum.Creature)
                {
                    using (CreatureRepository repo = new CreatureRepository(connectionString))
                    {
                        resultGameObject = repo.Add(gameObject as Creature);
                    }
                }
                else if (gameObject.GameObjectType == GameObjectTypeEnum.Item)
                {
                    using (ItemRepository repo = new ItemRepository(connectionString))
                    {
                        resultGameObject = repo.Add(gameObject as Item);
                    }
                }
                else if (gameObject.GameObjectType == GameObjectTypeEnum.Placeable)
                {
                    using (PlaceableRepository repo = new PlaceableRepository(connectionString))
                    {
                        resultGameObject = repo.Add(gameObject as Placeable);
                    }
                }
                else if (gameObject.GameObjectType == GameObjectTypeEnum.Script)
                {
                    using (ScriptRepository repo = new ScriptRepository(connectionString))
                    {
                        resultGameObject = repo.Add(gameObject as Script);
                    }
                }
                else if (gameObject.GameObjectType == GameObjectTypeEnum.Tileset)
                {
                    using (TilesetRepository repo = new TilesetRepository(connectionString))
                    {
                        resultGameObject = repo.Add(gameObject as Tileset);
                    }
                }
                else if (gameObject.GameObjectType == GameObjectTypeEnum.GameModule)
                {
                    using (GameModuleRepository repo = new GameModuleRepository())
                    {
                        resultGameObject = repo.Add(gameObject as GameModule);
                    }
                }
                else
                {
                    throw new NotSupportedException();
                }
            }
            catch
            {
                throw;
            }

            return resultGameObject;
        }
Example #46
0
        private void HandleAreaLoadEvent(object sender, ObjectSelectionEventArgs e)
        {
            Area selectedArea;
            using (AreaRepository repo = new AreaRepository())
            {
                selectedArea = repo.GetByID(e.ResourceID);
            }

            AreaEntityInstance.ChangeArea(selectedArea);
        }
Example #47
0
 /// <summary>
 /// Deletes an object with the specified resref from the database.
 /// </summary>
 /// <param name="resref">The resource reference to search for.</param>
 /// <param name="resourceType">The type of resource to remove.</param>
 /// <param name="connectionString">If you need to connect to a specific database, use this to pass the connection string. Otherwise, the default connection string will be used (WinterConnectionInformation.ActiveConnectionString)</param>
 public void DeleteFromDatabase(int resourceID, GameObjectTypeEnum resourceType, string connectionString = "")
 {
     if (resourceType == GameObjectTypeEnum.Area)
     {
         using (AreaRepository repo = new AreaRepository(connectionString))
         {
             repo.Delete(resourceID);
         }
     }
     else if (resourceType == GameObjectTypeEnum.Conversation)
     {
         using (ConversationRepository repo = new ConversationRepository(connectionString))
         {
             repo.Delete(resourceID);
         }
     }
     else if (resourceType == GameObjectTypeEnum.Creature)
     {
         using (CreatureRepository repo = new CreatureRepository(connectionString))
         {
             repo.Delete(resourceID);
         }
     }
     else if (resourceType == GameObjectTypeEnum.Item)
     {
         using (ItemRepository repo = new ItemRepository(connectionString))
         {
             repo.Delete(resourceID);
         }
     }
     else if (resourceType == GameObjectTypeEnum.Placeable)
     {
         using (PlaceableRepository repo = new PlaceableRepository(connectionString))
         {
             repo.Delete(resourceID);
         }
     }
     else if (resourceType == GameObjectTypeEnum.Script)
     {
         using (ScriptRepository repo = new ScriptRepository(connectionString))
         {
             repo.Delete(resourceID);
         }
     }
     else if (resourceType == GameObjectTypeEnum.Tileset)
     {
         using (TilesetRepository repo = new TilesetRepository(connectionString))
         {
             repo.Delete(resourceID);
         }
     }
     else if (resourceType == GameObjectTypeEnum.GameModule)
     {
         using (GameModuleRepository repo = new GameModuleRepository())
         {
             repo.Delete(resourceID);
         }
     }
     else
     {
         throw new NotSupportedException();
     }
 }
Example #48
0
        private void LoadTreeViewData(object sender, JavascriptMethodEventArgs e)
        {
            try
            {
                JSTreeNode areaRootNode;
                JSTreeNode creatureRootNode;
                JSTreeNode itemRootNode;
                JSTreeNode placeableRootNode;
                JSTreeNode conversationRootNode;
                JSTreeNode scriptRootNode;
                JSTreeNode tilesetRootNode;

                // Get each category's children for each object type
                using (AreaRepository repo = new AreaRepository())
                {
                    areaRootNode = repo.GenerateJSTreeHierarchy();
                }
                using (CreatureRepository repo = new CreatureRepository())
                {
                    creatureRootNode = repo.GenerateJSTreeHierarchy();
                }
                using (ItemRepository repo = new ItemRepository())
                {
                    itemRootNode = repo.GenerateJSTreeHierarchy();
                }
                using (PlaceableRepository repo = new PlaceableRepository())
                {
                    placeableRootNode = repo.GenerateJSTreeHierarchy();
                }
                using (ConversationRepository repo = new ConversationRepository())
                {
                    conversationRootNode = repo.GenerateJSTreeHierarchy();
                }
                using (ScriptRepository repo = new ScriptRepository())
                {
                    scriptRootNode = repo.GenerateJSTreeHierarchy();
                }
                using (TilesetRepository repo = new TilesetRepository())
                {
                    tilesetRootNode = repo.GenerateJSTreeHierarchy();
                }
                
                AsyncJavascriptCallback("LoadTreeViews_Callback",
                    JsonConvert.SerializeObject(areaRootNode),
                    JsonConvert.SerializeObject(creatureRootNode),
                    JsonConvert.SerializeObject(itemRootNode),
                    JsonConvert.SerializeObject(placeableRootNode),
                    JsonConvert.SerializeObject(conversationRootNode),
                    JsonConvert.SerializeObject(scriptRootNode),
                    JsonConvert.SerializeObject(tilesetRootNode));
            }
            catch
            {
                throw;
            }
        }
Example #49
0
        /// <summary>
        /// Delete all objects from database that match a specified resource category.
        /// </summary>
        /// <param name="resourceCategory">The resource category to remove all objects from.</param>
        /// <param name="resourceType">The type of resource to look for.</param>
        /// <param name="connectionString">If you need to connect to a specific database, use this to pass the connection string. Otherwise, the default connection string will be used (WinterConnectionInformation.ActiveConnectionString)</param>
        public void DeleteFromDatabaseByCategory(Category resourceCategory, GameObjectTypeEnum resourceType, string connectionString = "")
        {
            if (resourceType == GameObjectTypeEnum.Area)
            {
                using (AreaRepository repo = new AreaRepository(connectionString))
                {
                    repo.DeleteAllByCategory(resourceCategory);
                }
            }
            else if (resourceType == GameObjectTypeEnum.Conversation)
            {
                using (ConversationRepository repo = new ConversationRepository(connectionString))
                {
                    repo.DeleteAllByCategory(resourceCategory);
                }
            }
            else if (resourceType == GameObjectTypeEnum.Creature)
            {
                using (CreatureRepository repo = new CreatureRepository(connectionString))
                {
                    repo.DeleteAllByCategory(resourceCategory);
                }
            }
            else if (resourceType == GameObjectTypeEnum.Item)
            {
                using (ItemRepository repo = new ItemRepository(connectionString))
                {
                    repo.DeleteAllByCategory(resourceCategory);
                }
            }
            else if (resourceType == GameObjectTypeEnum.Placeable)
            {
                using (PlaceableRepository repo = new PlaceableRepository(connectionString))
                {
                    repo.DeleteAllByCategory(resourceCategory);
                }
            }
            else if (resourceType == GameObjectTypeEnum.Script)
            {
                using (ScriptRepository repo = new ScriptRepository(connectionString))
                {
                    repo.DeleteAllByCategory(resourceCategory);
                }
            }
            else if (resourceType == GameObjectTypeEnum.Tileset)
            {
                using (TilesetRepository repo = new TilesetRepository(connectionString))
                {
                    repo.DeleteAllByCategory(resourceCategory);
                }
            }
            else
            {
                throw new NotSupportedException();
            }

            // Now remove the category itself.
            using (CategoryRepository repo = new CategoryRepository())
            {
                Category dbCategory = repo.GetByID(resourceCategory.ResourceID);
                repo.Delete(dbCategory);
            }
        }
Example #50
0
        public void ListSignalAppliancesWithAlarmTypesAndValuesInOneRecord()
        {
            IRepository<SignalAppliance> dbSA = new SignalApplianceRepository();
            IRepository<Signal> dbS = new SignalRepository();
            IRepository<Appliance> dbApp = new ApplianceRepository();
            IRepository<SignalApplianceValue> dbSAppV = new SignalApplianceValueRepository();
            IRepository<AlarmType> dbAT = new AlarmTypeRepository();
            IRepository<Area> dbA = new AreaRepository();

            Area area = new Area();
            area = dbA.GetById(1);
            AlarmType normalAlarm = new AlarmType();
            normalAlarm = dbAT.GetById(1);
            AlarmType highAlarm = new AlarmType();
            highAlarm = dbAT.GetById(2);
            AlarmType lowAlarm = new AlarmType();
            lowAlarm = dbAT.GetById(3);

            Signal signal = new Signal();
            signal.Name = "PruebaSenal";
            signal.Description = "Prueba descriptiva senal";

            dbS.Save(signal);

            Appliance appliance = new Appliance();
            appliance.NameAppliance = "PruebaAppliance";
            appliance.Description = "Prueba descriptiva appliance";
            appliance.Area = area;

            SignalAppliance signalAppliance = new SignalAppliance();
            signalAppliance.Signal = signal;
            signalAppliance.Appliance = appliance;
            signalAppliance.Tolerance = SIGNAL_APPLIANCE_TOLERANCE;

            appliance.Signals.Add(signalAppliance);

            SignalApplianceValue normalValue = new SignalApplianceValue();
            normalValue.AlarmType = normalAlarm;
            normalValue.SignalAppliance = signalAppliance;
            normalValue.Value = SIGNAL_APPLIANCE_SET_POINT;

            SignalApplianceValue highValue = new SignalApplianceValue();
            highValue.AlarmType = highAlarm;
            highValue.SignalAppliance = signalAppliance;
            highValue.Value = SIGNAL_APPLIANCE_SET_POINT + SIGNAL_APPLIANCE_TOLERANCE;

            SignalApplianceValue lowValue = new SignalApplianceValue();
            lowValue.AlarmType = lowAlarm;
            lowValue.SignalAppliance = signalAppliance;
            lowValue.Value = SIGNAL_APPLIANCE_SET_POINT - SIGNAL_APPLIANCE_TOLERANCE;

            signalAppliance.SignalApplianceValues.Add(normalValue);
            signalAppliance.SignalApplianceValues.Add(highValue);
            signalAppliance.SignalApplianceValues.Add(lowValue);

            dbApp.Save(appliance);

            var result = from sa in dbSA.GetAll()
                                   join s in dbS.GetAll() on sa.Signal.Id equals s.Id
                                   join app in dbApp.GetAll() on sa.Appliance.Id equals app.Id
                                   join sapv in dbSAppV.GetAll() on sa.Id equals sapv.SignalAppliance.Id
                                   join a in dbAT.GetAll() on sapv.AlarmType.Id equals a.Id
                                   where sa.Id.Equals(signalAppliance.Id)
                                   group new {a.Id, a.NameAlarmType, sapv.Value } by new {sa.Id, app.NameAppliance, s.Name, sa.Tolerance} into g
                         select new { signalAppliance = g.Key, setPoint = from v in g where v.Id == 1 select v.Value, highValue = from v in g where v.Id == 2 select v.Value, lowValue = from v in g where v.Id == 3 select v.Value };

            foreach (var sa in result)
            {
                Assert.AreEqual(sa.signalAppliance.Id, signalAppliance.Id);
                ObjectDumper.Write(sa.setPoint);
                Assert.AreEqual(normalValue.Value, sa.setPoint.ElementAtOrDefault(0));
                ObjectDumper.Write(sa.highValue);
                Assert.AreEqual(highValue.Value, sa.highValue.ElementAtOrDefault(0));
                ObjectDumper.Write(sa.lowValue);
                Assert.AreEqual(lowValue.Value, sa.lowValue.ElementAtOrDefault(0));
            }

            dbSAppV.Delete(normalValue.Id);
            dbSAppV.Delete(highValue.Id);
            dbSAppV.Delete(lowValue.Id);

            dbSA.Delete(signalAppliance.Id);

            dbApp.Delete(appliance.Id);

            dbS.Delete(signal.Id);
        }
Example #51
0
        public void CanCreateSignalWithToleranceAndAssociatedSignalApplianceValues()
        {
            IRepository<Area> repoT = new AreaRepository();
            Area area = new Area();
            area = repoT.GetById(1);
            IRepository<AlarmType> repoAT = new AlarmTypeRepository();
            AlarmType normalAlarm = new AlarmType();
            normalAlarm = repoAT.GetById(1);
            AlarmType highAlarm = new AlarmType();
            highAlarm = repoAT.GetById(2);
            AlarmType lowAlarm = new AlarmType();
            lowAlarm = repoAT.GetById(3);

            IRepository<Signal> repoA = new SignalRepository();
            Signal signal = new Signal();
            signal.Name = "PruebaSenal";
            signal.Description = "Prueba descriptiva senal";

            repoA.Save(signal);

            IRepository<Appliance> repoB = new ApplianceRepository();
            Appliance appliance = new Appliance();
            appliance.NameAppliance = "PruebaAppliance";
            appliance.Description = "Prueba descriptiva appliance";
            appliance.Area = area;

            IRepository<SignalAppliance> repoSAppl = new SignalApplianceRepository();
            SignalAppliance signalAppliance = new SignalAppliance();
            signalAppliance.Signal = signal;
            signalAppliance.Appliance = appliance;
            signalAppliance.Tolerance = SIGNAL_APPLIANCE_TOLERANCE;

            appliance.Signals.Add(signalAppliance);

            IRepository<SignalApplianceValue> repoSApplV = new SignalApplianceValueRepository();
            SignalApplianceValue normalValue = new SignalApplianceValue();
            normalValue.AlarmType = normalAlarm;
            normalValue.SignalAppliance = signalAppliance;
            normalValue.Value = SIGNAL_APPLIANCE_SET_POINT;

            SignalApplianceValue highValue = new SignalApplianceValue();
            highValue.AlarmType = highAlarm;
            highValue.SignalAppliance = signalAppliance;
            highValue.Value = SIGNAL_APPLIANCE_SET_POINT + SIGNAL_APPLIANCE_TOLERANCE;

            SignalApplianceValue lowValue = new SignalApplianceValue();
            lowValue.AlarmType = lowAlarm;
            lowValue.SignalAppliance = signalAppliance;
            lowValue.Value = SIGNAL_APPLIANCE_SET_POINT - SIGNAL_APPLIANCE_TOLERANCE;

            signalAppliance.SignalApplianceValues.Add(normalValue);
            signalAppliance.SignalApplianceValues.Add(highValue);
            signalAppliance.SignalApplianceValues.Add(lowValue);

            repoB.Save(appliance);

            SignalApplianceValue createdNormalValue = repoSApplV.GetById(normalValue.Id);
            Assert.AreEqual(normalValue.Value, createdNormalValue.Value);

            SignalApplianceValue createdHighValue = repoSApplV.GetById(highValue.Id);
            Assert.AreEqual(highValue.Value, createdHighValue.Value);

            SignalApplianceValue createdLowValue = repoSApplV.GetById(lowValue.Id);
            Assert.AreEqual(lowValue.Value, createdLowValue.Value);

            repoSApplV.Delete(normalValue.Id);
            repoSApplV.Delete(highValue.Id);
            repoSApplV.Delete(lowValue.Id);

            repoSAppl.Delete(signalAppliance.Id);

            repoB.Delete(appliance.Id);

            repoA.Delete(signal.Id);
        }