Inheritance: DomainEntity
示例#1
0
 public virtual bool IsEmployeeAvailableForTask(Task task)
 {
     var startTime = DateTimeUtilities.StandardToMilitary(task.ScheduledStartTime.ToString());
     var endTime = DateTimeUtilities.StandardToMilitary(task.ScheduledEndTime.ToString());
     var conflictingTask = GetTasks().FirstOrDefault(x => x!=task
                                                   &&  (x.ScheduledDate == task.ScheduledDate
                                                   && DateTimeUtilities.StandardToMilitary(x.ScheduledStartTime.ToString()) < endTime
                                                   && DateTimeUtilities.StandardToMilitary(x.ScheduledEndTime.ToString()) > startTime));
     return conflictingTask == null;
 }
 public void Setup()
 {
     _continuation = new Continuation {Success = true};
     _validTask = ObjectMother.ValidTask("raif");
     _validTask.QuantityUsed = 5;
     _crudManager = MockRepository.GenerateMock<ICrudManager>();
     _crudManager.Expect(x => x.Finish()).Return(new Notification());
     _saveEntityService = MockRepository.GenerateMock<ISaveEntityService>();
     _sesCatcher = _saveEntityService.CaptureArgumentsFor(x => x.ProcessSave(_validTask.InventoryProduct, _crudManager), x => x.Return(_crudManager));
     _SUT = new InventoryService(null,_saveEntityService);
     _SUT.DecrementTaskProduct(_validTask, _crudManager);
 }
 public void Setup()
 {
     Bootstrapper.BootstrapTest();
     _field = ObjectMother.ValidField("Raif").WithEntityId(1);
     _task1 = ObjectMother.ValidTask("task1").WithEntityId(1);
     _task1.ScheduledStartTime = DateTime.Parse("1/2/2020 8:00 AM");
     _task2 = ObjectMother.ValidTask("task1").WithEntityId(2);
     _task2.ScheduledStartTime = DateTime.Parse("1/3/2020 8:00 AM");
     _task3 = ObjectMother.ValidTask("task1").WithEntityId(3);
     _task3.ScheduledStartTime = DateTime.Parse("1/1/2010 8:00 AM");
     _field.AddPendingTask(_task1);
     _field.AddPendingTask(_task2);
     _field.AddCompletedTask(_task3);
     _SUT = new FieldHasNoOutstandingTasks();
     _ruleResult = _SUT.Execute(_field);
 }
 public void Setup()
 {
     Bootstrapper.BootstrapTest();
     _systemClock = SystemClock.For(DateTime.Parse("1/1/2020 8:00 AM"));
     _employee = ObjectMother.ValidEmployee("Raif").WithEntityId(1);
     _task1 = ObjectMother.ValidTask("task1").WithEntityId(1);
     _task1.ScheduledStartTime = DateTime.Parse("1/2/2020 8:00 AM");
     _task2 = ObjectMother.ValidTask("task1").WithEntityId(2);
     _task2.ScheduledStartTime = DateTime.Parse("1/3/2020 8:00 AM");
     _task3 = ObjectMother.ValidTask("task1").WithEntityId(3);
     _task3.ScheduledStartTime = DateTime.Parse("1/1/2010 8:00 AM");
     _employee.AddTask(_task1);
     _employee.AddTask(_task2);
     _employee.AddTask(_task3);
     _SUT = new EmployeeHasNoOutstandingTasks(_systemClock);
     _ruleResult = _SUT.Execute(_employee);
 }
示例#5
0
 public virtual Task CloneTask()
 {
     var newTask = new Task
     {
         CreatedBy = CreatedBy,
         Field = Field,
         TaskType = TaskType,
         Notes = Notes,
         ScheduledDate = ScheduledDate,
         ScheduledEndTime = ScheduledEndTime,
         ScheduledStartTime = ScheduledStartTime,
         Status = Status,
         InventoryProduct = InventoryProduct
     };
     GetEmployees().Each(newTask.AddEmployee);
     return newTask;
 }
示例#6
0
 public virtual void RemoveTask(Task task)
 {
     _tasks.Remove(task);
 }
示例#7
0
 public virtual void AddTask(Task task)
 {
     if (!task.IsNew() && _tasks.Contains(task)) return;
     _tasks.Add(task);
 }
示例#8
0
 private void mapItem(Task item, Task input)
 {
     item.ScheduledDate = input.ScheduledDate;
     item.ScheduledStartTime = null;
     if (input.ScheduledStartTime.HasValue)
         item.ScheduledStartTime =
             DateTime.Parse(input.ScheduledDate.Value.ToShortDateString() + " " +
                            input.ScheduledStartTime.Value.ToShortTimeString());
     item.ScheduledEndTime = null;
     if (input.ScheduledEndTime.HasValue)
     {
         item.ScheduledEndTime = DateTime.Parse(input.ScheduledDate.Value.ToShortDateString() + " " + input.ScheduledEndTime.Value.ToShortTimeString());
     }
     item.ActualTimeSpent = input.ActualTimeSpent;
     item.QuantityNeeded = input.QuantityNeeded;
     item.QuantityUsed = input.QuantityUsed;
     item.Notes = input.Notes;
     item.Status = input.Status;
     item.Complete = input.Complete;
 }
示例#9
0
        private void mapChildren(Task task,TaskViewModel model)
        {
            task.ClearEmployees();
            task.ClearEquipment();
            if(model.EmployeeInput.IsNotEmpty())
                model.EmployeeInput.Split(',').Each(x => task.AddEmployee(_repository.Find<Employee>(Int32.Parse(x))));
            if(model.EquipmentInput.IsNotEmpty())
                model.EquipmentInput.Split(',').Each(x => task.AddEquipment(_repository.Find<Equipment>(Int32.Parse(x))));

            task.TaskType = _repository.Find<TaskType>(model.Task.TaskType.EntityId);
            task.Field = _repository.Find<Field>(model.Task.Field.EntityId);
            if (model.Product.IsNotEmpty())
            {
                var product = model.Product.Split('_');
                task.InventoryProduct= _repository.Find<InventoryProduct>(Int64.Parse(product[0]));
            }else
            {
                task.InventoryProduct = null;
            }
        }
示例#10
0
        private void CreateTask()
        {
            var taskType1 = new TaskType
            {
                Name = "Mow"
            };
            var taskType2 = new TaskType
            {
                Name = "Water"
            };
            _repository.Save(taskType1);
            _repository.Save(taskType2);
            _task1 = new Task
            {
                TaskType = taskType1,
                Field = _field1,
                ScheduledDate = DateTime.Parse("3/3/2011"),
                ScheduledStartTime = DateTime.Parse("3/3/2011 5:30 AM"),
                ScheduledEndTime = DateTime.Parse("3/3/2011 6:30 AM"),
                Notes = "Notes1",
                InventoryProduct = _invenotyMaterial1,
                QuantityNeeded = 4,
                UnitType = UnitType.Tons.ToString()
            };

            _task2 = new Task
            {
                TaskType = taskType2,
                Field=_field2,
                ScheduledDate = DateTime.Parse("3/3/2011"),
                ScheduledStartTime = DateTime.Parse("3/3/2011 6:30 AM"),
                ScheduledEndTime = DateTime.Parse("3/3/2011 7:30 AM"),
                Notes = "Notes2",
                InventoryProduct = _inventoryChemical2,
                QuantityNeeded = 4,
                UnitType = UnitType.Tons.ToString()
            };
            _task1.AddEmployee(_employee1);
            _task1.AddEmployee(_employee2);
            _task1.AddEquipment(_equip1);
            _task1.AddEquipment(_equip2);
            _task2.AddEmployee(_employee1);
            _task2.AddEmployee(_employee2);
            _task2.AddEquipment(_equip1);
            _task2.AddEquipment(_equip2);

            _repository.Save(_task1);
            _repository.Save(_task2);
        }
示例#11
0
 public virtual void RemovePendingTask(Task task)
 {
     _pendingTasks.Remove(task);
 }
示例#12
0
 public virtual void RemoveCompletedTask(Task task)
 {
     _completedTasks.Remove(task);
 }