public int CreateUserBuildingObject(int userId, int buildingObjectId, string host)
        {
            int result = 0;

            var user = _userRepository.FindById(userId);

            using (IUnitOfWork work = UnitOfWork.Begin())
            {
                UserBuildingObject ubo = DomainObjectFactory.CreateUserBuildingObject();

                var message = new XElement(XMLLogLiterals.LOG_MESSAGE);
                message.Add(XMLLogMessageHelper.TemplateToXml("LogMessageUserBuildingsChanged", new List <string> {
                    user.LoginName
                }));

                ubo.UserId           = userId;
                ubo.BuildingObjectId = buildingObjectId;
                ubo.IsDeleted        = false;

                _userBuildingObjectRepository.Add(ubo);

                work.Commit();
                ubo = _userBuildingObjectRepository.FindById(ubo.Id);
                message.Add(XMLLogMessageHelper.TemplateToXml("LogMessageUserBuildingAdded", new List <string> {
                    ubo.BuildingObject.Building.Name,
                    ubo.BuildingObject.Description
                }));

                result = ubo.Id;

                _logService.CreateLog(CurrentUser.Get().Id, "web", host, CurrentUser.Get().CompanyId, message.ToString());
            }

            return(result);
        }
Beispiel #2
0
        public void CreateEpisode_ValidEpisodeJsonData_EpisodeInstance()
        {
            // Arrange
            var json = File.ReadAllText(Path.Combine(BasePath, JSON_DATA_PATH, "episode.json"));

            // Act
            var episode = DomainObjectFactory.CreateEpisode(json);

            // Assert
            Assert.IsNotNull(episode);
            Assert.AreEqual(1, episode.Id);
            Assert.AreEqual("http://www.tvmaze.com/episodes/1/under-the-dome-1x01-pilot", episode.Url);
            Assert.AreEqual("Pilot", episode.Name);
            Assert.AreEqual(1, episode.Season);
            Assert.AreEqual(1, episode.Number);
            Assert.AreEqual("2013-06-24", episode.AirDate);
            Assert.AreEqual("22:00", episode.AirTime);
            Assert.AreEqual("2013-06-25T03:00:00+00:00", episode.AirStamp);
            Assert.AreEqual(DateTimeOffset.Parse("2013-06-25T03:00:00+00:00"), episode.AirDateTimeOffset);
            Assert.AreEqual(60, episode.RunTime);
            Assert.AreEqual(2, episode.Image.Count);
            Assert.AreEqual("http://static.tvmaze.com/uploads/images/medium_landscape/1/4388.jpg",
                            episode.Image[ImageType.Medium]);
            Assert.AreEqual("http://static.tvmaze.com/uploads/images/original_untouched/1/4388.jpg",
                            episode.Image[ImageType.Original]);
            Assert.AreEqual(
                "<p>When the residents of Chester's Mill find themselves trapped under a massive transparent dome with no way out, they struggle to survive as resources rapidly dwindle and panic quickly escalates.</p>",
                episode.Summary);
            Assert.AreEqual(1, episode.Links.Count);
            Assert.AreEqual("http://api.tvmaze.com/episodes/1", episode.Links[LinkType.Self].Href);
        }
        public int CreateDepartment(string number, string name, string createdBy, int companyId)
        {
            using (IUnitOfWork work = UnitOfWork.Begin())
            {
                Department department = DomainObjectFactory.CreateDepartment();

                department.Name         = name;
                department.Number       = number;
                department.ModifiedLast = DateTime.Now;
                department.ModifiedBy   = createdBy;
                department.CompanyId    = companyId;
                department.IsDeleted    = false;

                _departmentRepository.Add(department);

                work.Commit();

                department = _departmentRepository.FindById(department.Id);

                var departmentLogEntity = new DepartmentEventEntity(department);
                _logService.CreateLog(CurrentUser.Get().Id, "web", flag, CurrentUser.Get().HostName, CurrentUser.Get().CompanyId,
                                      departmentLogEntity.GetCreateMessage());

                return(department.Id);
            }
        }
Beispiel #4
0
        public int CreateLogWorkLeave(int userId, int boid, string flag, int?companyId, string action, DateTime eventtime, int logTypeId, string building, string node, string evntkey)
        {
            if (companyId == 0)
            {
                companyId = null;
            }

            int result = 0;

            using (IUnitOfWork work = UnitOfWork.Begin())
            {
                Log log = DomainObjectFactory.CreateLog();

                log.Action           = action;
                log.UserId           = userId;
                log.EventTime        = eventtime;
                log.CompanyId        = companyId;
                log.BuildingObjectId = boid;
                log.LogTypeId        = logTypeId;
                log.Building         = building;
                log.Node             = node;
                log.EventKey         = evntkey;
                _logRepository.Add(log);

                work.Commit();
                result = log.Id;
            }

            return(result);
        }
Beispiel #5
0
        public void CreateTAReport(int userId, int?departmentId, string name,
                                   DateTime ReportDate, Int16 day, float hours, int shift, byte status, Boolean completed, Boolean isDeleted)
        {
            using (IUnitOfWork work = UnitOfWork.Begin())
            {
                TAReport taReport = new TAReport();

                taReport              = DomainObjectFactory.CreateTAReport();
                taReport.UserId       = userId;
                taReport.DepartmentId = departmentId;
                taReport.Name         = name;
                //taReport.YearMonth = yearMonth;
                taReport.Day        = day;
                taReport.Hours      = hours;
                taReport.ReportDate = ReportDate;
                TimeSpan t = TimeSpan.FromSeconds(hours);
                taReport.Hours_Min    = string.Format("{0:D2}:{1:D2}:{2:D2}", t.Hours, t.Minutes, t.Seconds);
                taReport.Shift        = shift;
                taReport.Status       = status;
                taReport.Completed    = completed;
                taReport.IsDeleted    = isDeleted;
                taReport.Timestamp    = BitConverter.GetBytes(DateTime.Now.Ticks);
                taReport.ModifiedLast = DateTime.Now;
                taReport.ModifiedId   = CurrentUser.Get().Id;
                _taReportRepository.Add(taReport);
                work.Commit();

                var taReportLogEntity = new TAReportEventEntity(taReport);
                _logService.CreateLog(CurrentUser.Get().Id, "web", flag, CurrentUser.Get().HostName, CurrentUser.Get().CompanyId, taReportLogEntity.GetCreateMessage());

                string taReport_value = string.Format("{0} {1} {2}", name, hours, taReport.ModifiedLast.ToString("dd.MM.yyyy"));

                _controllerUpdateService.CreateControllerUpdate(CurrentUser.Get().Id, taReport.Id, UpdateParameter.TAReportChange, ControllerStatus.Created, taReport_value);
            }
        }
        public int CreateCardType(string name, bool isCardCode, bool isSerDK, string description)
        {
            int result = 0;

            using (IUnitOfWork work = UnitOfWork.Begin())
            {
                UserAccessUnitType cType = DomainObjectFactory.CreateUserAccessUnitType();

                cType.Name = name;
                cType.IsCardCode = isCardCode;
                cType.IsSerDK = isSerDK;
                cType.Description = description;
                cType.IsDeleted = false;

                _cardTypeRepository.Add(cType);

                var logCardTypeEntity = new CardTypeEventEntity(cType);

                work.Commit();

                result = cType.Id;

                _logService.CreateLog(CurrentUser.Get().Id, "web", flag, CurrentUser.Get().HostName,
                                      CurrentUser.Get().CompanyId, logCardTypeEntity.GetCreateMessage());
            }

            return result;
        }
        public int CreateCompanyBuildingObject(int companyId, int buildingObjectId, string host)
        {
            int result = 0;

            using (IUnitOfWork work = UnitOfWork.Begin())
            {
                CompanyBuildingObject cbo = DomainObjectFactory.CreateCompanyBuildingObject();

                cbo.CompanyId        = companyId;
                cbo.BuildingObjectId = buildingObjectId;
                cbo.ValidFrom        = DateTime.Now;
                cbo.ValidTo          = DateTime.Now.AddYears(2);
                cbo.IsDeleted        = false;

                _companyBuildingObjectRepository.Add(cbo);

                work.Commit();

                result = cbo.Id;

                cbo = _companyBuildingObjectRepository.FindById(result);

                var message = new StringBuilder();
                message.Append(string.Format("Building objects for Company '{0}' changed. ", cbo.Company.Name));
                message.Append(string.Format("Room '{0}' in '{1}' added. ", cbo.BuildingObject.Description,
                                             cbo.BuildingObject.Building.Name));

                _logService.CreateLog(CurrentUser.Get().Id, "web", flag, host, CurrentUser.Get().CompanyId, message.ToString());
            }

            return(result);
        }
Beispiel #8
0
        public void CreateHoliday(string name, string createdBy, DateTime eventStart, DateTime eventEnd, bool holidayMoving)
        {
            using (IUnitOfWork work = UnitOfWork.Begin())
            {
                Holiday holiday = DomainObjectFactory.CreateHoliday();

                holiday.Name          = name;
                holiday.EventStart    = eventStart;
                holiday.EventEnd      = eventStart; //eventEnd;
                holiday.ModifiedLast  = DateTime.Now;
                holiday.ModifiedBy    = createdBy;
                holiday.MovingHoliday = holidayMoving;
                holiday.IsDeleted     = false;

                _holidayRepository.Add(holiday);

                work.Commit();

                var holidayLogEntity = new HolidayEventEntity(holiday);

                _logService.CreateLog(CurrentUser.Get().Id, "web", flag, CurrentUser.Get().HostName, CurrentUser.Get().CompanyId,
                                      holidayLogEntity.GetCreateMessage());

                string holiday_value = string.Format("{0} {1} {1}", name, eventStart.ToString("dd.MM.yyyy"));

                _controllerUpdateService.CreateControllerUpdate(CurrentUser.Get().Id, holiday.Id, UpdateParameter.HolidayChange, ControllerStatus.Created, holiday_value);
            }
        }
Beispiel #9
0
        public void CreatePerson_ValidPersonJsonDataWithCastCredits_PersonInstanceWithCastCredits()
        {
            // Arrange
            var json = File.ReadAllText(Path.Combine(BasePath, JSON_DATA_PATH, "person_embed_castcredits.json"));

            // Act
            var person = DomainObjectFactory.CreatePerson(json);

            // Assert
            Assert.IsNotNull(person);
            Assert.AreEqual(1, person.Id);
            Assert.AreEqual("http://www.tvmaze.com/people/1/mike-vogel", person.Url);
            Assert.AreEqual("Mike Vogel", person.Name);
            Assert.AreEqual("United States", person.Country.Name);
            Assert.AreEqual("US", person.Country.Code);
            Assert.AreEqual("America/New_York", person.Country.Timezone);
            Assert.AreEqual(new DateTime(1979, 07, 17), person.Birthday);
            Assert.IsNull(person.Deathday);
            Assert.AreEqual(Gender.Male, person.Gender);
            Assert.IsNotEmpty(person.Image);
            Assert.IsTrue(person.Image.ContainsKey(ImageType.Medium));
            Assert.AreEqual("http://static.tvmaze.com/uploads/images/medium_portrait/0/1815.jpg", person.Image[ImageType.Medium]);
            Assert.IsNotNull(person.CastCredits);
            Assert.AreEqual("http://api.tvmaze.com/shows/1", person.CastCredits[0].Links[LinkType.Show].Href);
        }
        public int CreateOrFindBuildingFloorId(int buildingId, int floorNr, string description, int?objectNr = null)
        {
            int result = 0;

            using (IUnitOfWork work = UnitOfWork.Begin())
            {
                var floor = _buildingObjectRepository.FindAll(x => !x.IsDeleted && x.BuildingId == buildingId && x.TypeId == (int)BuildingObjectTypes.Floor && x.FloorNr == floorNr);

                if (floor.Count() == 0)
                {
                    BuildingObject bObject = DomainObjectFactory.CreateBuildingObject();

                    bObject.TypeId      = (int)BuildingObjectTypes.Floor;
                    bObject.BuildingId  = buildingId;
                    bObject.FloorNr     = floorNr;
                    bObject.Description = description;
                    bObject.IsDeleted   = false;
                    bObject.ObjectNr    = objectNr;

                    _buildingObjectRepository.Add(bObject);
                    work.Commit();

                    result = bObject.Id;
                }
                else
                {
                    result = floor.FirstOrDefault().Id;
                }
            }

            return(result);
        }
Beispiel #11
0
        public void AddUserDepartment(bool currentDep,
                                      int departmentId,
                                      bool isDeleted,
                                      bool isDepartmentManager,
                                      int userId,
                                      DateTime validFrom,
                                      DateTime validTo)
        {
            using (IUnitOfWork work = UnitOfWork.Begin())
            {
                UserDepartment ud = _userDepartmentRepository.FindByUserId(userId).Where(d => d.DepartmentId == departmentId).SingleOrDefault();

                if (ud == null)
                {
                    ud = DomainObjectFactory.CreateUserDepartment();
                    _userDepartmentRepository.Add(ud);
                }

                ud.CurrentDep          = currentDep;
                ud.DepartmentId        = departmentId;
                ud.IsDeleted           = isDeleted;
                ud.IsDepartmentManager = isDepartmentManager;
                ud.UserId    = userId;
                ud.ValidFrom = validFrom;
                ud.ValidTo   = validTo;

                work.Commit();

                var userDepLogEntity = new UserDepartmentEventEntity(_userDepartmentRepository.FindById(ud.Id));

                _logService.CreateLog(CurrentUser.Get().Id, "web", flag, CurrentUser.Get().HostName, CurrentUser.Get().CompanyId,
                                      userDepLogEntity.GetCreateMessage());
            }
        }
Beispiel #12
0
        public void SaveCompanyManager(int companyId, int userId, string host)
        {
            using (IUnitOfWork work = UnitOfWork.Begin())
            {
                CompanyManager companyManager =
                    _companyManagerRepository.FindAll(cm => cm.CompanyId == companyId).FirstOrDefault();

                if (companyManager == null)
                {
                    companyManager = DomainObjectFactory.CreateCompanyManager();
                    _companyManagerRepository.Add(companyManager);
                }

                companyManager.CompanyId = companyId;
                companyManager.UserId    = userId;
                companyManager.IsDeleted = false;

                work.Commit();

                companyManager = _companyManagerRepository.FindById(companyManager.Id);

                var message = new XElement(XMLLogLiterals.LOG_MESSAGE);
                message.Add(XMLLogMessageHelper.TemplateToXml("LogMessageSetCompanyManager", new List <string> {
                    companyManager.User.LoginName, companyManager.User.LastName
                }));

                _logService.CreateLog(CurrentUser.Get().Id, "web", flag, host, CurrentUser.Get().CompanyId, message.ToString());
            }
        }
        public ProjectsService(IDataUnitOfWork dataUnitOfWork, IObjectsLocator objectLocator)
        {
            domainObjectFactory = objectLocator.DomainObjectFactory;

            DataUnitOfWork = dataUnitOfWork;
            ObjectLocator  = objectLocator;
        }
Beispiel #14
0
        public void CreateShows_ValidShowsJsonData_ShowInstanceList()
        {
            // Arrange
            var json = File.ReadAllText(Path.Combine(BasePath, JSON_DATA_PATH, "shows.json"));

            // Act
            var shows = DomainObjectFactory.CreateShows(json);

            // Assert
            Assert.IsNotNull(shows);
            Assert.IsNotEmpty(shows);

            var show = shows[0];

            Assert.IsNotNull(show);
            Assert.AreEqual(1, show.Id);
            Assert.AreEqual("http://www.tvmaze.com/shows/1/under-the-dome", show.Url);
            Assert.AreEqual("Under the Dome", show.Name);
            Assert.AreEqual("Scripted", show.Type);
            Assert.AreEqual("English", show.Language);
            Assert.Contains("Drama", show.Genres);
            Assert.Contains("Science-Fiction", show.Genres);
            Assert.Contains("Thriller", show.Genres);
            Assert.AreEqual("Ended", show.Status);
            Assert.AreEqual(60, show.Runtime);
            Assert.AreEqual(new DateTime(2013, 06, 24), show.Premiered);
            Assert.AreEqual("http://www.cbs.com/shows/under-the-dome/", show.OfficialSite);
            Assert.AreEqual("22:00", show.Schedule.Time);
            Assert.Contains("Thursday", show.Schedule.Days);
            Assert.AreEqual(6.5m, show.Rating.Average);
            Assert.AreEqual(91, show.Weight);
            Assert.AreEqual(2, show.Network.Id);
            Assert.AreEqual("CBS", show.Network.Name);
            Assert.AreEqual("United States", show.Network.Country.Name);
            Assert.AreEqual("US", show.Network.Country.Code);
            Assert.AreEqual("America/New_York", show.Network.Country.Timezone);
            Assert.IsNull(show.WebChannel);
            Assert.IsNotNull(show.Externals);
            Assert.IsNotEmpty(show.Externals);
            Assert.IsTrue(show.Externals.ContainsKey("tvrage"));
            Assert.AreEqual("25988", show.Externals["tvrage"]);
            Assert.IsTrue(show.Externals.ContainsKey("thetvdb"));
            Assert.AreEqual("264492", show.Externals["thetvdb"]);
            Assert.IsTrue(show.Externals.ContainsKey("imdb"));
            Assert.AreEqual("tt1553656", show.Externals["imdb"]);
            Assert.IsNotEmpty(show.Image);
            Assert.IsTrue(show.Image.ContainsKey(ImageType.Medium));
            Assert.AreEqual("http://static.tvmaze.com/uploads/images/medium_portrait/0/1.jpg", show.Image[ImageType.Medium]);
            Assert.IsTrue(show.Image.ContainsKey(ImageType.Original));
            Assert.AreEqual("http://static.tvmaze.com/uploads/images/original_untouched/0/1.jpg", show.Image[ImageType.Original]);
            Assert.AreEqual("<p><b>Under the Dome</b> is the story of a small town that is suddenly and inexplicably sealed off from the rest of the world by an enormous transparent dome. The town's inhabitants must deal with surviving the post-apocalyptic conditions while searching for answers about the dome, where it came from and if and when it will go away.</p>",
                            show.Summary);
            Assert.AreEqual(1529612668, show.Updated);

            Assert.IsNull(show.Casts);
        }
Beispiel #15
0
        protected BaseIntegrationFixture()
        {
            _connectionString = CreateConnectionString();
            _database         = new Database(_connectionString.Value);
            _dbFactory        = new DatabaseFactory(_connectionString);
            _domainFactory    = new DomainObjectFactory();

            _resolver        = new Mock <IDependencyResolver>();
            _resolverFactory = new Mock <IDependencyResolverFactory>();
            _resolverFactory.Setup(f => f.CreateInstance()).Returns(_resolver.Object);
            _resolver.Setup(r => r.Resolve <ILog>()).Returns(new Mock <ILog>().Object);
            IoC.InitializeWith(_resolverFactory.Object);
        }
Beispiel #16
0
        public void UpdateUserDepartment(int userId, int departmentId, DateTime validFrom, DateTime validTo, bool isDelete)
        {
            using (IUnitOfWork work = UnitOfWork.Begin())
            {
                UserDepartment userDepartment = _userDepartmentRepository.FindByUserId(userId).Where(ud => ud.DepartmentId == departmentId).SingleOrDefault();

                if (userDepartment == null)
                {
                    userDepartment = DomainObjectFactory.CreateUserDepartment();
                    _userDepartmentRepository.Add(userDepartment);
                    userDepartment.UserId              = userId;
                    userDepartment.DepartmentId        = departmentId;
                    userDepartment.ValidFrom           = validFrom;
                    userDepartment.ValidTo             = validTo;
                    userDepartment.CurrentDep          = false;
                    userDepartment.IsDepartmentManager = userDepartment.IsDepartmentManager && !isDelete;
                    userDepartment.IsDeleted           = isDelete;

                    work.Commit();

                    var userDepLogEntity =
                        new UserDepartmentEventEntity(_userDepartmentRepository.FindById(userDepartment.Id));

                    _logService.CreateLog(CurrentUser.Get().Id, "web", flag, CurrentUser.Get().HostName, CurrentUser.Get().CompanyId,
                                          userDepLogEntity.GetCreateMessage());
                }
                else
                {
                    var userDepLogEntity =
                        new UserDepartmentEventEntity(userDepartment);
                    userDepartment.UserId              = userId;
                    userDepartment.DepartmentId        = departmentId;
                    userDepartment.ValidFrom           = validFrom;
                    userDepartment.ValidTo             = validTo;
                    userDepartment.CurrentDep          = false;
                    userDepartment.IsDepartmentManager = userDepartment.IsDepartmentManager && !isDelete;
                    userDepartment.IsDeleted           = isDelete;

                    work.Commit();

                    userDepLogEntity.SetNewUserDepartment(_userDepartmentRepository.FindById(userDepartment.Id));
                    _logService.CreateLog(CurrentUser.Get().Id, "web", flag, CurrentUser.Get().HostName, CurrentUser.Get().CompanyId,
                                          userDepLogEntity.GetEditMessage());
                }
            }
        }
        public int CreateUserBuilding(int userId, int buildingId, int?buildingObjectId, string host)
        {
            int result = 0;

            var user = _userRepository.FindById(userId);

            using (IUnitOfWork work = UnitOfWork.Begin())
            {
                UserBuilding ub = null;
                ub =
                    _userBuildingRepository.FindAll().Where(
                        x => x.UserId == userId && x.BuildingId == buildingId && x.BuildingObjectId == buildingObjectId).FirstOrDefault();
                var message = new XElement(XMLLogLiterals.LOG_MESSAGE);
                message.Add(XMLLogMessageHelper.TemplateToXml("LogMessageUserBuildingsChanged", new List <string> {
                    user.LoginName
                }));
                if (ub == null)
                {
                    ub = DomainObjectFactory.CreateUserBuilding();

                    ub.UserId           = userId;
                    ub.BuildingObjectId = buildingObjectId;
                    ub.IsDeleted        = false;
                    ub.BuildingId       = buildingId;

                    _userBuildingRepository.Add(ub);
                }
                else
                {
                    ub.IsDeleted = false;
                }

                work.Commit();
                ub = _userBuildingRepository.FindById(ub.Id);
                message.Add(XMLLogMessageHelper.TemplateToXml("LogMessageUserBuildingAdded", new List <string> {
                    ub.Building.Name,
                    ub.BuildingObject == null ? " " : ub.BuildingObject.Description
                }));

                result = ub.Id;

                _logService.CreateLog(CurrentUser.Get().Id, "web", flag, host, CurrentUser.Get().CompanyId, message.ToString());
            }

            return(result);
        }
Beispiel #18
0
        public void CreateAliases_ValidAliasJsonData_AliasList()
        {
            // Arrange
            var json = File.ReadAllText(Path.Combine(BasePath, JSON_DATA_PATH, "alias.json"));

            // Act
            var aliases = DomainObjectFactory.CreateAliases(json);

            // Assert
            Assert.IsNotNull(aliases);
            Assert.IsNotEmpty(aliases);

            var alias = aliases[1];

            Assert.AreEqual("A búra alatt", alias.Name);
            Assert.AreEqual("Hungary", alias.Country.Name);
        }
Beispiel #19
0
        public void CreateTAMove(int userId, int departmentId, string name,
                                 DateTime ReportDate, Int16 day, float hours, int shift, byte status, Boolean completed, Boolean isDeleted)
        {
            int _hours, _minutes;

            using (IUnitOfWork work = UnitOfWork.Begin())
            {
                TAReport taReport = DomainObjectFactory.CreateTAReport();
                taReport.UserId       = userId;
                taReport.DepartmentId = departmentId;
                taReport.Name         = name;
                //taReport.YearMonth = yearMonth;
                taReport.Day       = day;
                taReport.Hours     = hours;
                _hours             = (int)Math.Floor(hours);            // täisarvulised tunnid
                _minutes           = (int)((hours - _hours) * 60) % 60; // murdosa minutiteks
                taReport.Hours_Min = Convert.ToString(_hours) + ':';
                if (_minutes < 10)
                {
                    taReport.Hours_Min = taReport.Hours_Min + Convert.ToString(_minutes);
                }
                else
                {
                    taReport.Hours_Min = taReport.Hours_Min + '0' + Convert.ToString(_minutes);
                }
                taReport.Shift     = shift;
                taReport.Status    = status;
                taReport.Completed = completed;
                taReport.IsDeleted = isDeleted;
                taReport.Timestamp = BitConverter.GetBytes(DateTime.Now.Ticks);
                //              taReport.ScheduleNo = 1;
                taReport.ModifiedLast = DateTime.Now;
                taReport.ModifiedId   = CurrentUser.Get().Id;
                _taReportRepository.Add(taReport);
                work.Commit();

                var taReportLogEntity = new TAReportEventEntity(taReport);

                _logService.CreateLog(CurrentUser.Get().Id, "web", falg, CurrentUser.Get().HostName, CurrentUser.Get().CompanyId, taReportLogEntity.GetCreateMessage());

                string taReport_value = string.Format("{0} {1} {2}", name, hours, taReport.ModifiedLast.ToString("dd.MM.yyyy"));

                _controllerUpdateService.CreateControllerUpdate(CurrentUser.Get().Id, taReport.Id, UpdateParameter.TAReportChange, ControllerStatus.Created, taReport_value);
            }
        }
Beispiel #20
0
        public void CreateCrewCredits_ValidCrewCreditJsonData_CrewCreditList()
        {
            // Arrange
            var json = File.ReadAllText(Path.Combine(BasePath, JSON_DATA_PATH, "person_crewcredits.json"));

            // Act
            var crewCredits = DomainObjectFactory.CreateCrewCredits(json);

            // Assert
            Assert.IsNotNull(crewCredits);
            Assert.IsNotEmpty(crewCredits);

            var crewCredit = crewCredits[1];

            Assert.AreEqual("Consulting Producer", crewCredit.Type);
            Assert.AreEqual("http://api.tvmaze.com/shows/231", crewCredit.Links[LinkType.Show].Href);
            Assert.IsNull(crewCredit.Show);
        }
Beispiel #21
0
        public void CreateCastCredits_ValidCastCreditJsonData_CastCreditList()
        {
            // Arrange
            var json = File.ReadAllText(Path.Combine(BasePath, JSON_DATA_PATH, "person_castcredits.json"));

            // Act
            var castCredits = DomainObjectFactory.CreateCastCredits(json);

            // Assert
            Assert.IsNotNull(castCredits);
            Assert.IsNotEmpty(castCredits);

            var castCredit = castCredits[1];

            Assert.AreEqual("http://api.tvmaze.com/shows/942", castCredit.Links[LinkType.Show].Href);
            Assert.AreEqual("http://api.tvmaze.com/characters/89565", castCredit.Links[LinkType.Character].Href);
            Assert.IsNull(castCredit.Show);
        }
Beispiel #22
0
        public void CreateCrew_ValidCrewJsonData_CrewList()
        {
            // Arrange
            var json = File.ReadAllText(Path.Combine(BasePath, JSON_DATA_PATH, "crew.json"));

            // Act
            var crews = DomainObjectFactory.CreateCrews(json);

            // Assert
            Assert.IsNotNull(crews);
            Assert.IsNotEmpty(crews);

            var crew = crews[0];

            Assert.AreEqual("Creator", crew.Type);
            Assert.AreEqual(15, crew.Person.Id);
            Assert.AreEqual("Stephen King", crew.Person.Name);
        }
Beispiel #23
0
        public void CreateShowUpdates_ValidShowUpdatesJsonData_ShowUpdateInstanceList()
        {
            // Arrange
            var json = File.ReadAllText(Path.Combine(BasePath, JSON_DATA_PATH, "show_updates.json"));

            // Act
            var showUpdates = DomainObjectFactory.CreateShowUpdates(json);

            // Assert
            Assert.IsNotNull(showUpdates);
            Assert.IsNotEmpty(showUpdates);

            var showUpdate = showUpdates[0];

            Assert.AreEqual("1", showUpdate.ShowId);
            Assert.AreEqual(1488136720, showUpdate.Timestamp);
            Assert.AreEqual(DateTimeOffset.Parse("2017-02-26T19:18:40+00:00"), showUpdate.DateTimeOffset);
        }
Beispiel #24
0
        public void CreateSchedule_ValidScheduleJsonData_ScheduleList()
        {
            // Arrange
            var json = File.ReadAllText(Path.Combine(BasePath, JSON_DATA_PATH, "schedule.json"));

            // Act
            var schedule = DomainObjectFactory.CreateSchedule(json);

            // Assert
            Assert.IsNotNull(schedule);
            Assert.IsNotEmpty(schedule.Episodes);

            var episode = schedule.Episodes[0];

            Assert.IsNotNull(episode);
            Assert.IsNotNull(episode.Show);
            Assert.AreEqual(1588998, episode.Id);
        }
Beispiel #25
0
        public void InsertLicencePathintbl(int id)
        {
            using (IUnitOfWork work = UnitOfWork.Begin())
            {
                IEnumerable <ClassificatorValue> cv = _classificatorValueRepository.FindByValue("Licence Path");

                if (cv.ToList().Count == 0)
                {
                    ClassificatorValue cv1 = DomainObjectFactory.CreateClassificatorValue();

                    cv1.ClassificatorId = id;
                    cv1.Value           = "Licence Path";
                    cv1.SortOrder       = 8;
                    _classificatorValueRepository.Add(cv1);
                    work.Commit();
                }
            }
        }
Beispiel #26
0
        public int CreateLog(int userId, string building, string flag, string node, int?companyId, string action, int?logTypeId = null)
        {
            if (companyId == 0)
            {
                companyId = null;
            }

            int result = 0;

            using (IUnitOfWork work = UnitOfWork.Begin())
            {
                Log log = DomainObjectFactory.CreateLog();

                log.UserId    = userId;
                log.CompanyId = companyId;
                log.Action    = action;
                log.Building  = building;
                log.Node      = node;

                if (flag == "Log")
                {
                    log.LogTypeId = 15;
                }
                else
                {
                    if (!logTypeId.HasValue)
                    {
                        log.LogTypeId = (int)LogTypeEnum.WebInfo;
                    }
                    else
                    {
                        log.LogTypeId = logTypeId.Value;
                    }
                }

                log.EventTime = DateTime.Now;
                _logRepository.Add(log);

                work.Commit();
                result = log.Id;
            }

            return(result);
        }
Beispiel #27
0
        public void CreateClassificator(string name, string comment, string host)
        {
            using (IUnitOfWork work = UnitOfWork.Begin())
            {
                Classificator c = DomainObjectFactory.CreateClassificator();

                c.Description = name;
                c.Comments    = comment;

                _classificatorRepository.Add(c);

                work.Commit();

                var classificatorLogEntity = new ClassificatorEventEntity(c);

                _logService.CreateLog(CurrentUser.Get().Id, "web", flag, host, CurrentUser.Get().CompanyId,
                                      classificatorLogEntity.GetCreateMessage());
            }
        }
Beispiel #28
0
        public void CreatePeopleSearchResults_ValidSearchPeopleJsonData_PersonSearchResults()
        {
            // Arrange
            var json = File.ReadAllText(Path.Combine(BasePath, JSON_DATA_PATH, "search_people.json"));

            // Act
            var searchResults = DomainObjectFactory.CreatePeopleSearchResults(json);

            // Assert
            Assert.IsNotNull(searchResults);
            Assert.IsNotEmpty(searchResults);

            var searchResult = searchResults[1];

            Assert.AreEqual(29.037012m, searchResult.Score);
            Assert.IsNotNull(searchResult.Element);
            Assert.IsInstanceOf <Person>(searchResult.Element);
            Assert.AreEqual(5028, searchResult.Element.Id);
            Assert.AreEqual("Lauren German", searchResult.Element.Name);
        }
Beispiel #29
0
        public void CreateCast_ValidCastJsonData_CastList()
        {
            // Arrange
            var json = File.ReadAllText(Path.Combine(BasePath, JSON_DATA_PATH, "cast.json"));

            // Act
            var casts = DomainObjectFactory.CreateCasts(json);

            // Assert
            Assert.IsNotNull(casts);
            Assert.IsNotEmpty(casts);

            var cast = casts[0];

            Assert.AreEqual(1, cast.Person.Id);
            Assert.AreEqual("Mike Vogel", cast.Person.Name);
            Assert.AreEqual(1, cast.Character.Id);
            Assert.AreEqual("Dale \"Barbie\" Barbara", cast.Character.Name);
            Assert.IsFalse(cast.Self);
            Assert.IsFalse(cast.Voice);
        }
Beispiel #30
0
        public void CreateShowSearchResults_ValidSearchShowJsonData_ShowSearchResults()
        {
            // Arrange
            var json = File.ReadAllText(Path.Combine(BasePath, JSON_DATA_PATH, "search_show.json"));

            // Act
            var searchResults = DomainObjectFactory.CreateShowSearchResults(json);

            // Assert
            Assert.IsNotNull(searchResults);
            Assert.IsNotEmpty(searchResults);

            var searchResult = searchResults[0];

            Assert.AreEqual(17.15518m, searchResult.Score);
            Assert.IsNotNull(searchResult.Element);
            Assert.IsInstanceOf <Show>(searchResult.Element);
            Assert.AreEqual(139, searchResult.Element.Id);
            Assert.AreEqual("http://www.tvmaze.com/shows/139/girls", searchResult.Element.Url);
            Assert.AreEqual("Girls", searchResult.Element.Name);
            Assert.AreEqual("Scripted", searchResult.Element.Type);
        }