Пример #1
0
        /// <summary>
        /// بروز رسانی اطلاعات کارمند
        /// </summary>
        /// <param name="employee">کارمند</param>
        /// <returns>کارمند با اطلاعات بروز شده</returns>
        public Employee UpdateEmployee(Employee employee)
        {
            Employee updatedEmployee = PersistenceObjectRepository <Employee> .Update(employee);

            m_profilePictureRepository.Save(updatedEmployee.ID.ToString(), updatedEmployee.ProfilePicture);
            return(updatedEmployee);
        }
        public void Update_WhenCalled_ContactInformationIsUpdated()
        {
            ContactInformation returnValue = PersistenceObjectRepository <ContactInformation> .Create(newContactInformationSample());

            returnValue.Label = "Work";
            ContactInformation updatedValue = PersistenceObjectRepository <ContactInformation> .Update(returnValue);

            Expect(updatedValue.Label, Is.EqualTo(returnValue.Label));
        }
        public void Update_WhenCalled_EmployeeIsUpdated()
        {
            Employee returnValue = PersistenceObjectRepository <Employee> .Create(newEmployeeSample());

            returnValue.FirstName = "Mohammad";
            Employee updatedValue = PersistenceObjectRepository <Employee> .Update(returnValue);

            Expect(updatedValue.FirstName, Is.EqualTo(returnValue.FirstName));
        }
Пример #4
0
        /// <summary>
        /// ثبت ساعت خروج
        /// </summary>
        /// <param name="employee">کارمند</param>
        /// <returns>زمان خروج</returns>
        public AttendanceTime RegisterEmployeeExitTime(Employee employee)
        {
            if (employee == null)
            {
                return(null);
            }
            ///[Registering exit time]
            AttendanceTime attendanceTime = new AttendanceTime();

            attendanceTime = RetrieveAttendanceTimes().Where((at) => at.Employee == employee).Last();
            attendanceTime.Employee.ProfilePicture = m_profilePictureRepository.Read(attendanceTime.Employee.ID.ToString());
            attendanceTime.ExitTime = DateTime.Now;

            return(PersistenceObjectRepository <AttendanceTime> .Update(attendanceTime));

            ///[Registering exit time]
        }
Пример #5
0
        private void INSERT_SAMPLE_DATA(bool insert = true, bool truncate_old_data = false)
        {
            if (!insert)
            {
                return;
            }

            if (truncate_old_data)
            {
                PersistenceObjectRepository <AttendanceTime> .Truncate();
            }

            if (false)
            {
                foreach (Employee employee in RetrieveEmployees())
                {
                    employee.WorkSchedule.DefineRange(DayOfWeek.Saturday, 9, 17, WorkSchedule.State.Work);
                    employee.WorkSchedule.DefineRange(DayOfWeek.Sunday, 9, 17, WorkSchedule.State.Work);
                    employee.WorkSchedule.DefineRange(DayOfWeek.Monday, 9, 17, WorkSchedule.State.Work);
                    employee.WorkSchedule.DefineRange(DayOfWeek.Tuesday, 9, 17, WorkSchedule.State.Work);
                    employee.WorkSchedule.DefineRange(DayOfWeek.Wednesday, 9, 17, WorkSchedule.State.Work);
                    employee.WorkSchedule.DefineRange(DayOfWeek.Thursday, 9, 17, WorkSchedule.State.Work);
                    PersistenceObjectRepository <Employee> .Update(employee);
                }
            }

            List <AttendanceTime> attendanceTimeSampleData = new List <AttendanceTime>();
            int       year      = 2014;
            int       month     = DateTime.Now.Month;
            int       day       = DateTime.Now.Day - 5;
            DayOfWeek dayofWeek = (new DateTime(year, month, day)).DayOfWeek;

            attendanceTimeSampleData.Add(new AttendanceTime()
            {
                Employee = RetrieveEmployees()[4], //Binda Binder
                //AttendanceHours = new WorkSchedule(),
                EntryTime = new DateTime(year, month, day, 09, 0, 0, 0),
                ExitTime  = new DateTime(year, month, day, 21, 0, 0, 0)
            });


            attendanceTimeSampleData.Add(new AttendanceTime()
            {
                Employee = RetrieveEmployees()[2], //محمد طالبی
                //   AttendanceHours = new WorkSchedule(),
                EntryTime = new DateTime(year, month, day, 09, 0, 0, 0),
                ExitTime  = new DateTime(year, month, day, 17, 0, 0, 0)
            });


            attendanceTimeSampleData.Add(new AttendanceTime()
            {
                Employee  = RetrieveEmployees()[0], //Abbas Allahyari
                EntryTime = new DateTime(year, month, day, 18, 0, 0),
                ExitTime  = new DateTime(year, month, day, 23, 0, 0),
                //    AttendanceHours = new WorkSchedule(),
            });


            foreach (AttendanceTime at in attendanceTimeSampleData)
            {
                PersistenceObjectRepository <AttendanceTime> .Create(at);
            }

            List <ContactInformation> contactInformationSampleData = new List <ContactInformation>()
            {
                new ContactInformation()
                {
                    Label           = "Home",
                    PhoneNumber     = "02199115532",
                    CellphoneNumber = "09126512321",
                    Email           = "*****@*****.**",
                    Address         = "No 3, Valiasr, Tehran",
                    PostalCode      = "1434567891",
                    Employee        = RetrieveEmployees()[0]
                },
                new ContactInformation()
                {
                    Label           = "Grandpa",
                    PhoneNumber     = "02188115532",
                    CellphoneNumber = "09326512321",
                    Email           = "*****@*****.**",
                    Address         = "No 5, Ponak, Tehran",
                    PostalCode      = "1434567893",
                    Employee        = RetrieveEmployees()[0]
                }
            };

#if false
            RetrieveEmployees()[0].ContactInformations.Add(contactInformationSampleData[0]);
            RetrieveEmployees()[0].ContactInformations.Add(contactInformationSampleData[1]);
            PersistenceObjectRepository <Employee> .Update(RetrieveEmployees()[0]);
#endif
        }