Beispiel #1
0
        private void SaveTask(TaskDto task, int userId)
        {
            var user    = _userRepository.GetByUserID(userId);
            var project = _projectRepository.GetById(task.ProjectId);

            Trex.Server.Core.Model.Task parentTask = null;

            if (task.ParentTaskId.HasValue)
            {
                parentTask = _taskRepository.GetById(task.ParentTaskId.Value);
            }

            if (!_taskRepository.ExistsByGuid(task.Guid))
            {
                var newTask = _taskFactory.Create(task.Guid,
                                                  task.CreateDate,
                                                  task.ChangeDate,
                                                  task.Name,
                                                  task.Description,
                                                  user,
                                                  project,
                                                  null,
                                                  parentTask,
                                                  task.WorstCaseEstimate,
                                                  task.BestCaseEstimate,
                                                  task.RealisticEstimate,
                                                  task.TimeEstimated,
                                                  task.TimeLeft
                                                  );

                _taskRepository.SaveOrUpdate(newTask);
                task.Id   = newTask.TaskID;
                task.Guid = newTask.Guid;
            }
            else
            {
                var originalTask = _taskRepository.GetByGuid(task.Guid);

                originalTask.TaskName          = task.Name;
                originalTask.Description       = task.Description;
                originalTask.ParentTask        = parentTask;
                originalTask.Project           = project;
                originalTask.RealisticEstimate = task.RealisticEstimate;
                originalTask.BestCaseEstimate  = task.BestCaseEstimate;
                originalTask.WorstCaseEstimate = task.WorstCaseEstimate;
                originalTask.TimeEstimated     = task.TimeEstimated;
                originalTask.TimeLeft          = task.TimeLeft;

                _taskRepository.SaveOrUpdate(originalTask);
            }
        }
Beispiel #2
0
        public void TestFixtureSetUp()
        {
            //Use In Memory database, open session and Build Schema inside In Memory database
            _dataSession = new DataSession(SQLiteConfiguration.Standard.InMemory());
            _session     = _dataSession.SessionFactory.OpenSession();
            BuildSchema(_session, _dataSession.Configuration);

            //create user
            var plantRepository = new GenericRepository <User>(_session);

            _user = DataGenerator.GetUser();
            _user = plantRepository.SaveOrUpdate(_user);

            //create customer
            var customer = DataGenerator.GetCustomer(_user);

            customer = new GenericRepository <Company>(_session).SaveOrUpdate(customer);

            //Create project under customer
            _project = DataGenerator.GetProject(_user, customer);
            _project = new GenericRepository <Project>(_session).SaveOrUpdate(_project);

            //add project to user
            _user.Projects.Add(_project);
            _user = plantRepository.SaveOrUpdate(_user);

            //create task
            var taskRepository = new TaskRepository(_session);

            _task = taskRepository.SaveOrUpdate(DataGenerator.GetTask(_project, _user));

            //create timeEntryType
            var timeEntryTypeRepository = new TimeEntryTypeRepository(_session);

            _timeEntryType = timeEntryTypeRepository.SaveOrUpdate(DataGenerator.GetTimeEntryType(customer));
        }
Beispiel #3
0
 //public static UserCustomerInfo UserCustomerInfo()
 //{
 //    var userCustomerInfo = new UserCustomerInfo();
 //    return userCustomerInfo;
 //}
 public static TimeEntry GetTimeEntry(Task task, User user, TimeEntryType timeEntryType)
 {
     return(new TimeEntry(Guid.NewGuid(), DateTime.Now, DateTime.Now, timeEntryType, string.Empty, 0, 0, 0, true, 0, task, user, 0));
 }