public OrganisationalUnitInfoViewModel(OrganisationalUnitInfo entity)
        {
            Id = entity.Id;

            if (entity.Category != null)
            {
                CategoryID = entity.Category.Id;
                CategoryName = entity.Category.Name;
            }
            
            OrganisationalUnitId = entity.OrganisationalUnitId;
            Name = entity.Name;
            ShortDescription = entity.ShortDescription;
            LongDescription = entity.LongDescription;

            if (entity.Category != null && (entity.ImagePath == ""))
            {
                if (entity.Category.Name == "Grundskola")
                {
                    ImagePath = "grund.jpg";
                }
                else if (entity.Category.Name == "Förskola")
                {
                    ImagePath = "dagis.jpg";
                }
                else if (entity.Category.Name == "Gymnasieskola")
                {
                    ImagePath = "gymnasieskola.jpg";
                }
                else if (entity.Category.Name == "Sjukhus")
                {
                    ImagePath = "sjukhus.jpg";
                }
                else if (entity.Category.Name == "Äldreboende")
                {
                    ImagePath = "elderly.jpg";
                }
                else if (entity.Category.Name == "Vårdcentral")
                {
                    ImagePath = "vardcentral.jpg";
                }
            }
            else if (entity.ImagePath != "")
            {
                ImagePath = entity.ImagePath;
            }
            else
            {
                ImagePath = "default.jpg";
            }
            Address = entity.Address;
            Telephone = entity.Telephone;
            Contact = entity.Contact;
            Email = entity.Email;
            OrganisationalForm = entity.OrganisationalForm;
            Website = entity.Website;
            Latitude = entity.Latitude;
            Longitude = entity.Longitude;
            Other = entity.Other;
        }
        public void Test_KoladaTownWebService_GetOrganisationalUnitTest()
        {
            string UnitId = "V15E108000901";
            var expected = new OrganisationalUnitInfo();
            expected.Id = 3;
            expected.Name = "Fridlevstads skola F-6";
            expected.OrganisationalUnitId = "V15E108000901";

            _webService = new KoladaTownWebService();
            var actual = _webService.GetOrganisationalUnit(UnitId);

            Assert.AreEqual(actual.Name, expected.Name);
            Assert.AreEqual(actual.OrganisationalUnitId, expected.OrganisationalUnitId);
        }
        public void Test_Settings_DeclareOrganisationalUnitInfo()
        {
            int id = 4;
            string name = "testName";

            var ouTest = new OrganisationalUnitInfo();
            try
            {
                ouTest.Id = id;
                ouTest.Name = name;
            }
            catch
            {
                Assert.Fail();
            }
           
        }
Ejemplo n.º 4
0
        public bool UpdateOrganisationalUnitInfo(OrganisationalUnitInfo ou)
        {
            try
            {
                _unitOfWork.OrganisationalUnitInfoRepository.Update(ou);
                _unitOfWork.Save();
                return true;
            }
            catch { }

            return false;
        }
        public void Test_NullId_OrganisationalUnitInfo()
        {
            string key = "cacheKey";
            OrganisationalUnitInfo ouInfo = new OrganisationalUnitInfo();
            CacheManager cache = new CacheManager();

            cache.SetCache(key, ouInfo.Id);

            var expected = cache.GetCache(key);

            Assert.AreEqual(expected, 0);

        }
        public OrganisationalUnitInfo ToEntity(OrganisationalUnitInfo existing = null)
        {
            OrganisationalUnitInfo entity = (existing != null ? existing : new OrganisationalUnitInfo());

            entity.Id = this.Id;
            entity.OrganisationalUnitId = this.OrganisationalUnitId;
            entity.Name = this.Name;
            entity.ShortDescription = this.ShortDescription;
            entity.LongDescription = this.LongDescription;
            entity.ImagePath = this.ImagePath;
            entity.Address = this.Address;
            entity.Telephone = this.Telephone;
            entity.Contact = this.Contact;
            entity.Email = this.Email;
            entity.OrganisationalForm = this.OrganisationalForm;
            entity.Website = this.Website;
            entity.Latitude = this.Latitude;
            entity.Longitude = this.Longitude;
            entity.Other = this.Other;

            return entity;
        }