示例#1
0
        public void ChangeTasks(Task[] tasks)
        {
            bool changed = false;
            if (tasks.Length != Tasks.Count())
            {
                changed = true;
            }
            else
            {
                foreach (var pair in Tasks.Zip(tasks, (t1, t2) => Tuple.Create(t1, t2)))
                {
                    if (pair.Item1.Name != pair.Item2.Name ||
                        pair.Item1.Rate != pair.Item2.Rate)
                    {
                        changed = true;
                        break;
                    }
                }
            }

            if (changed)
            {
                ApplyChange(new ProjectTasksChanged(Id, tasks.Select(t => new Dtos.Task { Name = t.Name, Rate = t.Rate }).ToArray()));
            }
        }
 public TimeRegistration(Guid id, Client client, Project project, Task task,
                         string description, Date date, Time from, Time to)
 {
     ApplyChange(new TimeRegistrationCreated(id, client.Id, project.Id, 
                                             task.Name, task.Rate,
                                             description, date, from, to, 
                                             DateTime.UtcNow));
 }
        public void ChangeDetails(Client client, Project project, Task task,
                                  string description, Date date, Time from, Time to)
        {
            if (Deleted)
                throw new AggregateDeletedException();

            if (ClientId != client.Id || ProjectId != project.Id ||
                Task != task.Name || Description != description ||
                Date != date || From != from || To != to)
            {
                ApplyChange(new TimeRegistrationDetailsChanged(Id, client.Id, project.Id,
                                                               task.Name, description, date, from, to));
            }
        }
        public void RefreshRate(Task task)
        {
            if (Deleted)
                throw new AggregateDeletedException();

            if (Rate != task.Rate)
            {
                ApplyChange(new TimeRegistrationRateRefreshed(Id, task.Rate));
            }
        }
 protected override void Because()
 {
     _task = _project.FindTask("dEveloPment");
 }