Example #1
0
        public void CreatePoll(string pollQuestion, string[] pollOptions, int threadID)
        {
            System.Data.Objects.DataClasses.EntityCollection<PollOption> toadd = new System.Data.Objects.DataClasses.EntityCollection<PollOption>();

            foreach (string po in pollOptions)
            {
                toadd.Add(new PollOption
                {
                    Text = po,
                    PollID = threadID
                });
            }

            Poll ThePoll = new Poll
            {
                PollOptions = toadd,
                Question = pollQuestion,
                PollID = threadID
            };

            _pollRepository.Add(ThePoll);
            Thread thread = _threadRepository.Get(threadID);
            thread.HasPoll = true;
            _threadRepository.Update(thread);
            _unitOfWork.Commit();
        }
 public void MustFillFirstAlertHeaderWithEntityObject()
 {
     //Arrange
     Mock<IFirstAlertView> mockView = new Mock<IFirstAlertView>();
     Mock<FirstAlertModel>  mockModel = new Mock<FirstAlertModel>();
     System.Data.Objects.DataClasses.EntityCollection<CS_FirstAlertDivision> divisions = new System.Data.Objects.DataClasses.EntityCollection<CS_FirstAlertDivision>();
     divisions.Add(new CS_FirstAlertDivision() { CS_Division = new CS_Division() {ID=1, Name="001"}});
     divisions.Add(new CS_FirstAlertDivision() { CS_Division = new CS_Division() {ID=1, Name="002"}});
     CS_FirstAlert firstAlertStub =  new CS_FirstAlert()
         {
             ID=1,
            CS_Job = new CS_Job() { ID=1, Number = "1234"},
             CS_Customer = new CS_Customer() {ID=2, Name = "Customer 1" },
             CS_Employee_InCharge = new CS_Contact() { ID = 2, Name = "Peter", LastName = "Parker", Active = true},
             CS_FirstAlertDivision = divisions,
             Date = new DateTime(2011, 7, 12, 5, 0, 0),
             CS_Country = new CS_Country() { ID = 1, Name = "USA" },
             CS_State = new CS_State() { ID = 1, Name = "Florida" },
             CS_City = new CS_City() { ID = 1, Name = "Miami" },
             ReportedBy = "danilo",
             CS_Employee_CompletedBy = new CS_Employee() { ID = 1, FirstName = "Danilo", Name = "Ruziska" },
             Details = "details",
             HasPoliceReport = true,
             PoliceAgency = "agency",
             PoliceReportNumber = "1234"
         } ;
     mockView.SetupProperty(e => e.FirstAlertID, 1);
     mockView.SetupProperty(e => e.FirstAlertEntity, null);
     mockModel.Setup(e => e.GetFirstAlertById(1)).Returns(firstAlertStub);
     FirstAlertPresenter presenter = new FirstAlertPresenter(mockView.Object, mockModel.Object);
     //Act
     presenter.FillFirstAlertHeaderFields();
     //Assert
     Assert.AreEqual(firstAlertStub.CS_Job.Number,  mockView.Object.FirstAlertEntity.CS_Job.Number);
     Assert.AreEqual(firstAlertStub.CS_Customer.ID, mockView.Object.FirstAlertEntity.CS_Customer.ID);
     Assert.AreEqual(firstAlertStub.CS_Employee_InCharge.ID,  mockView.Object.FirstAlertEntity.CS_Employee_InCharge.ID);
     Assert.AreEqual(firstAlertStub.CS_FirstAlertDivision.Count,  mockView.Object.FirstAlertEntity.CS_FirstAlertDivision.Count);
     Assert.AreEqual(firstAlertStub.Date, mockView.Object.FirstAlertEntity.Date);
     Assert.AreEqual(firstAlertStub.CS_Country.ID,  mockView.Object.FirstAlertEntity.CS_Country.ID);
     Assert.AreEqual(firstAlertStub.CS_City.ID, mockView.Object.FirstAlertEntity.CS_City.ID);
     Assert.AreEqual(firstAlertStub.CS_State.ID, mockView.Object.FirstAlertEntity.CS_State.ID);
     Assert.AreEqual(firstAlertStub.ReportedBy, mockView.Object.FirstAlertEntity.ReportedBy);
     Assert.AreEqual(firstAlertStub.CS_Employee_CompletedBy.ID, mockView.Object.FirstAlertEntity.CS_Employee_CompletedBy.ID);
     Assert.AreEqual(firstAlertStub.ReportedBy, mockView.Object.FirstAlertEntity.ReportedBy);
     Assert.AreEqual(firstAlertStub.Details, mockView.Object.FirstAlertEntity.Details);
     Assert.AreEqual(firstAlertStub.HasPoliceReport, mockView.Object.FirstAlertEntity.HasPoliceReport);
     Assert.AreEqual(firstAlertStub.PoliceAgency,  mockView.Object.FirstAlertEntity.PoliceAgency);
     Assert.AreEqual(firstAlertStub.PoliceReportNumber, mockView.Object.FirstAlertEntity.PoliceReportNumber);
 }
Example #3
0
        public void ConfigurateForStudent()
        {

            this.grid1.Visibility = System.Windows.Visibility.Visible;
            this.grid1.IsHitTestVisible = true;

            this.bCurWeek.Visibility = System.Windows.Visibility.Visible;
            this.bAllGroups.Visibility = System.Windows.Visibility.Visible;
            this.bMySchedule.Visibility = System.Windows.Visibility.Visible;

            this.bShowSchedule.Visibility = System.Windows.Visibility.Visible;
            this.bMySchedule2.Visibility = System.Windows.Visibility.Visible;

            this.selfScheduleAction = this.SelfSchedule_Student;

            if (DBController.Instance.User != null)
            {
                this.lessonCollection = DBController.Instance.User.studentsgroup.lessons;
            }
            this.ShowSchedule(true);
        }
        public Thread CreateThread(
            int forumID,
            int userID,
            string threadTitle,
            ThreadType threadType,
            string threadImage,
            string message,
            string pollText,
            string[] pollOptions,
            HttpPostedFileBase[] files)
        {
            Thread thread = new Thread
            {
                ForumID = forumID,
                Type = (int)threadType,
                Image = threadImage,
                Title = threadTitle,
                HasPoll = false
            };

            string parsedMessage = _parseServices.ParseBBCodeText(message);

            var firstPost = new Post()
            {
                UserID = userID,
                Date = DateTime.UtcNow,
                ThreadID = thread.ThreadID,
                TextOnly = _parseServices.GetTextOnly(message),
                Text = message,
                ParsedText = parsedMessage
            };

            thread.Posts.Add(firstPost);

            if (!string.IsNullOrWhiteSpace(pollText))
            {
                Poll poll = new Poll
                {
                    Question = pollText,
                    PollID = thread.ThreadID
                };

                thread.Poll = poll;

                var options = new System.Data.Objects.DataClasses.EntityCollection<PollOption>();
                foreach (string po in pollOptions)
                {
                    poll.PollOptions.Add(new PollOption
                    {
                        Text = po
                    });
                }
                thread.HasPoll = true;
            }

            if (files != null)
            {
                foreach (var file in files)
                {
                    string savedName = _fileServices.UploadFile(file);
                    firstPost.Attachments.Add(new Attachment()
                    {
                        Downloaded = 0,
                        SavedName = savedName,
                        DownloadName = file.FileName,
                        Size = file.ContentLength,
                        Type = file.ContentType
                    });
                }
            }
            _threadRepository.Add(thread);
            _unitOfWork.Commit();
            return thread;
        }
Example #5
0
        public void ConfigurateForTeacher()
        {

            this.grid1.Visibility = System.Windows.Visibility.Visible;
            this.grid1.IsHitTestVisible = true;
            this.bCurWeek.Visibility = System.Windows.Visibility.Visible;
            this.bAllGroups.Visibility = System.Windows.Visibility.Visible;
            this.bMySchedule.Visibility = System.Windows.Visibility.Visible;
            this.bShowSchedule.Visibility = System.Windows.Visibility.Visible;
            this.bMySchedule2.Visibility = System.Windows.Visibility.Visible;

            this.selfScheduleAction = this.SelfSchedule_Teacher;
            this.cellDoubleClickedAction = this.CellDoubleClicked_Teacher;

            if (DBController.Instance.User != null)
            {
                this.lessonCollection = DBController.Instance.User.lessons;
            }
            this.ShowSchedule(true);
        }
Example #6
0
        void ShowSchedule(bool IsMine = false)
        {
            if (IsMine)
            {
                this.tbGroupName.Text = "Ваше расписание";
            }
            else
            {
                studentsgroup sg = (studentsgroup)this.groupList.SelectedItem;
                if (sg != null)
                {
                    this.lessonCollection = sg.lessons;
                    this.tbGroupName.Text = "Группа " + sg.Name;
                }
            }

            this.timeTable.FirstDay = this.GetCurrentWeekMonday();
            this.timeTable.FillTable(DBModel.Instance.GetLessonsByPeriodAndRef(this.lessonCollection, this.timeTable.FirstDay, this.timeTable.FirstDay.AddDays(14)));

            this.ShowTimeTable();

            
        }
Example #7
0
 void SelfSchedule_Teacher(Object data)
 {
     //Set this.lessonCollection to teacher.lessons and invoke ShowSchedule method
     if (DBController.Instance.User != null)
     {
         this.lessonCollection = DBController.Instance.User.lessons;
     }
     this.ShowSchedule(true);
 }
Example #8
0
 void SelfSchedule_Student(Object data)
 { 
     //Set this.lessonCollection to student.lessons and invoke ShowSchedule method
     if (DBController.Instance.User != null)
     {
         this.lessonCollection = DBController.Instance.User.studentsgroup.lessons;
     }
     this.ShowSchedule(true);
 }
Example #9
0
 public static System.Data.Objects.DataClasses.EntityCollection<PMS.Model.Context.PMS_CYCLE_STAGE> MapCycleStageDTOsToEntities(List<PMS.Model.DTO.Cycle.Stage> dto)
 {
     System.Data.Objects.DataClasses.EntityCollection<PMS.Model.Context.PMS_CYCLE_STAGE> lst_entities = new System.Data.Objects.DataClasses.EntityCollection<Context.PMS_CYCLE_STAGE>();
     foreach (PMS.Model.DTO.Cycle.Stage obj_entity in dto)
     {
         lst_entities.Add(MapCycleStageDTOToEntity(obj_entity));
     }
     return lst_entities;
 }
        public void MustReturnEmployeeInfo()
        {
            //Arrange
            Mock<IEmployeeMaintenanceView> mockView = new Mock<IEmployeeMaintenanceView>();
            Mock<EmployeeModel> mockModel = new Mock<EmployeeModel>();
            System.Data.Objects.DataClasses.EntityCollection<CS_EmployeeEmergencyContact> employeeContacts = new System.Data.Objects.DataClasses.EntityCollection<CS_EmployeeEmergencyContact>();
            employeeContacts.Add(new CS_EmployeeEmergencyContact() { Active = true, EmployeeID = 1, FirstName = "Margie", LastName = "Simpson", HomeAreaCode = "11", HomePhone = "89431267" });
            CS_Employee employeeStub = new CS_Employee()
            {
                ID = 1,
                PersonID = "123",
                FirstName = "Danilo",
                Name = "Ruziska",
                HireDate = new DateTime(2011, 8, 31),
                Address = "Elm Street, 123",
                Address2 = "Third Floor",
                City = "Houston",
                StateProvinceCode = "TX",
                CountryCode = "USA",
                PostalCode = "12345",
                BusinessCardTitle = "Software Developer",
                CS_Division = new CS_Division() { ID = 1, Active = true, Name = "001" },
                PassportNumber = "12345abc",
                CS_EmployeeEmergencyContact = employeeContacts,
                HomeAreaCode = "11",
                HomePhone = "123456",
                MobileAreaCode = "12",
                MobilePhone = "34567",
                OtherPhoneAreaCode = "13",
                OtherPhone = "98765",
                IsDentonPersonal = true,
                DriversLicenseNumber = "123",
                DriversLicenseClass = "A",
                DriversLicenseStateProvinceCode = "TX",
                DriversLicenseExpireDate = new DateTime(2012, 12, 21)
            };

            mockView.SetupProperty(e => e.EmployeeId, 1);
            mockView.SetupProperty(e => e.EmployeeName, "");
            mockView.SetupProperty(e => e.HireDate, null);
            mockView.SetupProperty(e => e.PersonID, "");
            mockView.SetupProperty(e => e.Address, "");
            mockView.SetupProperty(e => e.Address2, "");
            mockView.SetupProperty(e => e.City, "");
            mockView.SetupProperty(e => e.State, "");
            mockView.SetupProperty(e => e.Country, "");
            mockView.SetupProperty(e => e.PostalCode, "");
            mockView.SetupProperty(e => e.Position, "");
            mockView.SetupProperty(e => e.EmployeeDivision, "");
            mockView.SetupProperty(e => e.PassportNumber, "");
            mockView.SetupProperty(e => e.EmployeeContacts, null);
            mockView.SetupProperty(e => e.HomePhone, "");
            mockView.SetupProperty(e => e.HomeAreaCode, "");
            mockView.SetupProperty(e => e.MobileAreaCode, "");
            mockView.SetupProperty(e => e.MobilePhone, "");
            mockView.SetupProperty(e => e.OtherPhoneAreaCode, "");
            mockView.SetupProperty(e => e.OtherPhone, "");
            mockView.SetupProperty(e => e.IsDentonPersonal, false);
            mockView.SetupProperty(e => e.DriversLicenseNumber, "");
            mockView.SetupProperty(e => e.DriversLicenseClass, "");
            mockView.SetupProperty(e => e.DriversLicenseState, "");
            mockView.SetupProperty(e => e.DriversLicenseExpireDate, null);
            mockModel.Setup(e => e.GetEmployee(1)).Returns(employeeStub);

            EmployeeMaintenancePresenter presenter = new EmployeeMaintenancePresenter(mockView.Object, mockModel.Object);
            //Act
            presenter.LoadEmployeeInfo();
            //Assert
            Assert.AreEqual("Danilo,Ruziska", mockView.Object.EmployeeName);
            Assert.AreEqual(new DateTime(2011, 8, 31), mockView.Object.HireDate);
            Assert.AreEqual("123", mockView.Object.PersonID);
            Assert.AreEqual("Software Developer", mockView.Object.Position);
            Assert.AreEqual("001", mockView.Object.EmployeeDivision);
            Assert.AreEqual("12345abc", mockView.Object.PassportNumber);
            Assert.AreEqual(1, mockView.Object.EmployeeContacts.Count);
            Assert.AreEqual("Elm Street, 123", mockView.Object.Address);
            Assert.AreEqual("Third Floor", mockView.Object.Address2);
            Assert.AreEqual("Houston", mockView.Object.City);
            Assert.AreEqual("TX", mockView.Object.State);
            Assert.AreEqual("USA", mockView.Object.Country);
            Assert.AreEqual("12345", mockView.Object.PostalCode);
            Assert.AreEqual("11", mockView.Object.HomeAreaCode);
            Assert.AreEqual("123456", mockView.Object.HomePhone);
            Assert.AreEqual("12", mockView.Object.MobileAreaCode);
            Assert.AreEqual("34567", mockView.Object.MobilePhone);
            Assert.AreEqual("13", mockView.Object.OtherPhoneAreaCode);
            Assert.AreEqual("98765", mockView.Object.OtherPhone);
            Assert.IsTrue(mockView.Object.IsDentonPersonal);
            Assert.AreEqual("123", mockView.Object.DriversLicenseNumber);
            Assert.AreEqual("A", mockView.Object.DriversLicenseClass);
            Assert.AreEqual("TX", mockView.Object.DriversLicenseState);
            Assert.AreEqual(new DateTime(2012, 12, 21), mockView.Object.DriversLicenseExpireDate);
        }