コード例 #1
0
        public void HiredOnDecember()
        {
            var target = new Employee();

            var calculator = new CalculateVacations()
            {
                Context = new ScriptContext(),
                HiringDate = DateTime.Parse("2011-12-15"),
                Vacations = new List<Vacation>(),
                Now = DateTime.Parse("2011-12-30")
            };

            var calculated = calculator.Execute();
            var expected = 1;
            int actual = calculated.TotalPending;
            Assert.AreEqual(expected, actual);
        }
コード例 #2
0
        public static EmployeeMenuDTO Create(Employee employee, Menu menuDefinition, EmployeeMenu employeeMenu, MenuOrder lastOrder)
        {
            employeeMenu.EmployeeName = string.Format("{0}, {1}", employee.LastName, employee.FirstName);

            var result = new EmployeeMenuDTO
            {
                EmployeeMenu = employeeMenu,
                MenuDefinition = menuDefinition
            };

            if (lastOrder != null && lastOrder.DetailByUserName.ContainsKey(employee.UserName))
            {
                var detail = lastOrder.DetailByUserName[employee.UserName];
                result.LastOrder = new EmployeeMenuOrderDTO()
                {
                    Date = menuDefinition.LastOrderDate,
                    Option = detail.OptionKey == null ? null : lastOrder.OptionsByKey[detail.OptionKey],
                    Place = detail.PlaceKey == null ? null : lastOrder.PlacesByKey[detail.PlaceKey],
                    Comment = detail.Comment,
                    Food = detail.OptionKey == null ? null : lastOrder.FoodsByOption[detail.OptionKey],
                    WeekIdx = lastOrder.WeekIdx,
                    DayIdx = lastOrder.DayIdx,
                    IsOrdered = true
                };
            }
            else if (lastOrder != null)
            {
                result.LastOrder = new EmployeeMenuOrderDTO()
                {
                    Date = menuDefinition.LastOrderDate,
                    Option = null,
                    Place = null,
                    Comment = "// El usuario no existía al momento de hacer el pedido //",
                    Food = null,
                    WeekIdx = lastOrder.WeekIdx,
                    DayIdx = lastOrder.DayIdx,
                    IsOrdered = true
                };
            }

            return result;
        }
コード例 #3
0
        private void MoveFromSlot(Employee employee, string attachmentId)
        {
            var slot = employee.AttachmentsBySlot.Where(x => x.SlotId == SlotId && x.Attachment != null && x.Attachment.Id == attachmentId).First();

            var note = new NoteWithAttachment()
            {
                Note = DownNoteText,
                Attachment = slot.Attachment,
                RealDate = slot.Date,
                RegisterDate = slot.Date
            };

            if (employee.Notes == null)
            {
                employee.Notes = new List<NoteWithAttachment>();
            }

            employee.Notes.Add(note);

            employee.AttachmentsBySlot.Remove(slot);
        }
コード例 #4
0
        public void HiredFourYearsAgo()
        {
            var target = new Employee();

            var calculator = new CalculateVacations()
            {
                Context = CreateContext(),
                Configuration = new VacationsReportConfiguration()
                {
                    CurrentYear = 2011,
                    DetailedYearsQuantity = 5
                },
                Data = new VacationsReportData()
                {
                    HiringDate = DateTime.Parse("2007-3-15"),
                    Vacations = new Vacation[0]
                }
            };

            var calculated = calculator.Execute();
            var expected = 70;
            int actual = calculated.TotalPending;
            Assert.AreEqual(expected, actual);
        }
コード例 #5
0
 private Employee CreateEmployee(string name)
 {
     var newEmployee = new Employee(name);
     RavenSession.Store(newEmployee);
     return newEmployee;
 }
コード例 #6
0
        private static void QuickAttachToNotes(Employee employee, AttachmentReference[] attachments)
        {
            var notes = attachments.Select(x => new NoteWithAttachment()
            {
                Attachment = x,
                Note = "QuickAttachment!",
                RealDate = DateTime.Now,
                RegisterDate = DateTime.Now
            });

            if (employee.Notes == null)
            {
                employee.Notes = notes.ToList();
            }
            else
            {
                employee.Notes.AddRange(notes);
            }
        }
コード例 #7
0
 public ImportKey(Employee employee)
     : this(employee.LastName, employee.FirstName)
 {
 }
コード例 #8
0
        private void MoveToSlot(Employee employee, string attachmentId)
        {
            if (employee.AttachmentsBySlot == null)
            {
                employee.AttachmentsBySlot = new List<SlotWithAttachment>();
            }

            var note = employee.Notes.Where(x => x.Attachment != null && x.Attachment.Id == attachmentId).First();
            var slot = employee.AttachmentsBySlot.Where(x => x.SlotId == SlotId).FirstOrDefault();
            if (slot == null)
            {
                slot = new SlotWithAttachment() { SlotId = SlotId };
                employee.AttachmentsBySlot.Add(slot);
            }

            if (slot.Attachment == null)
            {
                slot.Date = note.RegisterDate;
                slot.Attachment = note.Attachment;

                if (string.IsNullOrWhiteSpace(note.Note) || note.Note == DownNoteText)
                {
                    employee.Notes.Remove(note);
                }
                else
                {
                    note.Attachment = null;
                }
            }
        }
コード例 #9
0
 public AbsencesSearchResult(Employee employee, IEnumerable<Absence> absences, IEnumerable<Vacation> vacations)
 {
     Id = employee.Id;
     FirstName = employee.FirstName;
     LastName = employee.LastName;
     HiringDate = employee.HiringDate;
     TerminationDate = employee.TerminationDate;
     Absences = absences.Select(x => new AbsenceResult(x)).Union(vacations.Select(x => new AbsenceResult(x))).ToList();
 }
コード例 #10
0
        public void HiringDateUnset()
        {
            var target = new Employee();

            var calculator = new CalculateVacations()
            {
                Context = CreateContext(),
                Configuration = new VacationsReportConfiguration()
                {
                    CurrentYear = 2011,
                    DetailedYearsQuantity = 5
                },
                Data = VacationsReportData.FromEmployee(target)
            };

            var result = calculator.Execute();
        }
コード例 #11
0
 private Employee CreateEmployee()
 {
     var newEmployee = new Employee();
     RavenSession.Store(newEmployee);
     return newEmployee;
 }
コード例 #12
0
ファイル: Applicant.cs プロジェクト: sofipacifico/CommonJobs
        public Employee Hire(DateTime hiringDate)
        {
            var employee = new Employee();
            employee.HiringDate = hiringDate;

            //It is not sooo elegant but works
            employee.IdChanged += (sender, e) =>
            {
                EmployeeId = employee.Id;
            };

            employee.FirstName = FirstName;
            employee.LastName = LastName;
            employee.Address = Address;
            employee.ApplicantId = Id;
            employee.BirthDate = BirthDate;
            employee.College = College;
            employee.Degree = Degree;
            employee.Email = Email;
            employee.EnglishLevel = EnglishLevel;
            employee.IsGraduated = IsGraduated;
            employee.MaritalStatus = MaritalStatus;
            employee.Skills = Skills;
            employee.TechnicalSkills = TechnicalSkills;
            employee.Telephones = Telephones;
            //employee.Photo = Photo //I am not sure because of entity associated to attachments

            return employee;
        }
コード例 #13
0
 public void TotalDaysTest_StartAndEndDateIncluded()
 {
     var target = new Employee();
     target.HiringDate = DateTime.Parse("2010-06-10T23:00:00");
     target.Vacations = new List<Vacation>() {
         new Vacation() { Period = 2010, From = DateTime.Parse("2012-01-01T00:00:00"), To = DateTime.Parse("2012-01-10T00:00:00") }
     };
     var calculator = new CalculateVacations() {
         Context = new ScriptContext(),
         Employee = target
     };
     var calculated = calculator.Execute();
     var expected = 10;
     int actual = calculated.TotalTaken;
     Assert.AreEqual(expected, actual);
 }
コード例 #14
0
 public void IgnoreVacationsBeforHiring()
 {
     var target = new Employee();
     target.HiringDate = DateTime.Parse("2010-06-10T23:00:00");
     target.Vacations = new List<Vacation>() {
         new Vacation() { Period = 2009, From = DateTime.Parse("2012-01-01T20:00:00"), To = DateTime.Parse("2012-01-1T20:00:00") }
     };
     var calculator = new CalculateVacations()
     {
         Context = new ScriptContext(),
         HiringDate = target.HiringDate,
         Vacations = target.Vacations
     };
     var calculated = calculator.Execute();
     var expected = 0;
     int actual = calculated.TotalTaken;
     Assert.AreEqual(expected, actual);
 }
コード例 #15
0
        public void HiringDateUnset()
        {
            var target = new Employee();

            var calculator = new CalculateVacations()
            {
                Context = new ScriptContext(),
                Vacations = new List<Vacation>(),
                Now = DateTime.Parse("2011-6-15")
            };

            try
            {
                var calculated = calculator.Execute();
            }
            catch (ScriptCommandException e)
            {
                return;
            }
            Assert.Fail("There should be a ScriptCommandException");
        }
コード例 #16
0
 public static VacationsReportData FromEmployee(Employee employee)
 {
     return new VacationsReportData()
     {
         HiringDate = employee.HiringDate,
         Vacations = employee.Vacations.ToArray()
     };
 }