Ejemplo n.º 1
0
 public GridRowItemViewModel(TimeEntry timeEntry, TimeEntryType timeEntryType)
 {
     TimeEntry        = timeEntry;
     EditableType     = timeEntryType;
     EditableBillable = TimeEntry.Billable;
     HasChanges       = false;
 }
        //private void CreateTimeEntryTypeCompleted(TimeEntryType newTimeEntryType)
        //{
        //    var timeEntryTypeViewModel = new TimeEntryTypeViewModel(newTimeEntryType);

        //    //control the default type
        //    if (newTimeEntryType.IsDefault)
        //        SetAsDefault(newTimeEntryType);

        //    TimeEntryTypes.Add(timeEntryTypeViewModel);

        //    //If its a global type, commit immediately
        //    if (newTimeEntryType.IsGlobal)
        //        Commit();

        //}

        private void EditTimeEntryTypeCompleted(TimeEntryType timeEntryType)
        {
            //control the default type
            if (timeEntryType.IsDefault)
            {
                SetAsDefault(timeEntryType);
            }

            var timeEntryTypeViewModel = TimeEntryTypes.SingleOrDefault(t => t.TimeEntryType.TimeEntryTypeId == timeEntryType.TimeEntryTypeId);

            //If its a new one, we´ll add it
            if (timeEntryTypeViewModel == null)
            {
                timeEntryTypeViewModel = new TimeEntryTypeViewModel(timeEntryType);
                TimeEntryTypes.Add(timeEntryTypeViewModel);
                if (DataReady != null)
                {
                    DataReady(this, null);
                }
            }

            //If its a global type, commit immediately
            if (timeEntryType.Customer == null)
            {
                Commit();
            }
        }
Ejemplo n.º 3
0
        public async Task <List <TimeEntryType> > GetAllTimeEntryTypes()
        {
            using (var client = _serviceFactory.GetServiceClient(_userSession.LoginSettings))
            {
                try
                {
                    var timeEntryTypes = await client.GetAllTimeEntryTypesAsync();

                    var returnList = new List <TimeEntryType>();
                    foreach (var timeEntryType in timeEntryTypes)
                    {
                        returnList.Add(TimeEntryType.Create(
                                           timeEntryType.Id,
                                           timeEntryType.IsDefault,
                                           timeEntryType.IsBillableByDefault,
                                           timeEntryType.Name,
                                           timeEntryType.CustomerId
                                           ));
                    }

                    return(returnList);
                }
                catch (CommunicationException ex)
                {
                    throw new ServiceAccessException("Error when uploading timeentries", ex);
                }
            }
        }
        public EditTimeEntryTypeViewModel(IDataService dataService, TimeEntryType timeEntryType)
        {
            _timeEntryType = timeEntryType;

            _dataService      = dataService;
            SaveTimeEntryType = new DelegateCommand <object>(ExecuteSaveTimeEntryType, CanSaveTimeEntryType);
        }
Ejemplo n.º 5
0
        private void EditTimeEntryTypeStart(TimeEntryType timeEntryType)
        {
            var editTimeEntryTypeView      = new EditTimeEntryTypeView();
            var editTimeEntryTypeViewModel = new EditTimeEntryTypeViewModel(_dataService, timeEntryType);

            editTimeEntryTypeView.ViewModel = (editTimeEntryTypeViewModel);
            editTimeEntryTypeView.Show();
        }
Ejemplo n.º 6
0
 public TimeEntryEventDto(Guid id, string?user, DateTimeOffset when, TimeEntryType type, Guid job)
 {
     Id   = id;
     User = user;
     When = when;
     Type = type;
     Job  = job;
 }
Ejemplo n.º 7
0
 public void SetTimeEntryType(TimeEntryType selectTimeEntryType)
 {
     foreach (var dayItemViewmodel in TimeEntries)
     {
         dayItemViewmodel.TimeEntryType = selectTimeEntryType;
     }
     HasChanges = true;
     OnPropertyChanged(() => TimeEntries);
 }
Ejemplo n.º 8
0
        public TimeEntryType SaveTimeEntryType(TimeEntryType timeEntryType)
        {
            using (var db = _entityContext.TrexEntityContext)
            {
                db.TimeEntryTypes.ApplyChanges(timeEntryType);
                db.SaveChanges();
            }

            return(timeEntryType);
        }
Ejemplo n.º 9
0
 public static TrexPortalService.TimeEntryTypeDto ConvertFromModelToService(TimeEntryType timeEntryType)
 {
     return(new TrexPortalService.TimeEntryTypeDto()
     {
         Name = timeEntryType.Name,
         CustomerId = timeEntryType.CustomerId,
         IsBillableByDefault = timeEntryType.IsBillableByDefault,
         IsDefault = timeEntryType.IsDefault,
         Id = timeEntryType.Id
     });
 }
Ejemplo n.º 10
0
 public TimeEntryType SaveTimeEntryType(TimeEntryType timeEntryType)
 {
     try
     {
         return(_timeEntryService.SaveTimeEntryType(timeEntryType));
     }
     catch (Exception ex)
     {
         LogError(ex);
         return(null);
     }
 }
Ejemplo n.º 11
0
        public static TimeEntryType Create(int id, bool isDefault, bool isBillableByDefault, string name, int?customerId)
        {
            var timeEntryType = new TimeEntryType()
            {
                Id                  = id,
                IsDefault           = isDefault,
                IsBillableByDefault = isBillableByDefault,
                Name                = name,
                CustomerId          = customerId
            };

            return(timeEntryType);
        }
Ejemplo n.º 12
0
        public TimeEntry Create(Guid guid, User user, Task task, TimeEntryType timeEntryType, DateTime startTime, DateTime endTime, string description, double timeSpent, double pauseTime, double billableTime, bool billable, double price, int clientSourceId)
        {
            if (task == null)
            {
                throw new ParameterNullOrEmptyException("Task cannot be null");
            }

            if (user == null)
            {
                throw new ParameterNullOrEmptyException("User createdBy cannot be null");
            }

            return(new TimeEntry(guid, startTime, endTime, timeEntryType, description, timeSpent, pauseTime, billableTime, billable, price, task, user, clientSourceId));
        }
        public async Task <Guid> With(string when, TimeEntryType type, Guid?id = null)
        {
            if (!id.HasValue)
            {
                id = Guid.NewGuid();
            }

            var ids = await _mediator.Send(
                new CreateTimeEntries(new TimeEntryModel(
                                          DateTimeOffset.Parse(when),
                                          (int)type,
                                          UserProfileScenarioBuilder.Job1,
                                          id)));

            return(ids.First());
        }
Ejemplo n.º 14
0
        private void CreateTimeEntryTypeStart(Customer customer)
        {
            var timeEntryType = new TimeEntryType();

            if (customer != null)
            {
                timeEntryType.Customer = customer;
                customer.TimeEntryTypes.Add(timeEntryType);
                timeEntryType.CustomerId = customer.Id;
            }

            var editTimeEntryTypeView      = new EditTimeEntryTypeView();
            var editTimeEntryTypeViewModel = new EditTimeEntryTypeViewModel(_dataService, timeEntryType);

            editTimeEntryTypeView.ViewModel = (editTimeEntryTypeViewModel);
            editTimeEntryTypeView.Show();
        }
Ejemplo n.º 15
0
        public static TimeEntryType ToDtoObject(this Trex.Server.Core.Model.TimeEntryType timeEntryType)
        {
            var dtoTimeEntryType = new TimeEntryType();

            if (timeEntryType.Customer != null)
            {
                dtoTimeEntryType.CustomerId = timeEntryType.Customer.Id;
            }

            dtoTimeEntryType.Id = timeEntryType.Id;
            dtoTimeEntryType.IsBillableByDefault = timeEntryType.IsBillableByDefault;
            dtoTimeEntryType.IsDefault           = timeEntryType.IsDefault;
            dtoTimeEntryType.Name = timeEntryType.Name;


            return(dtoTimeEntryType);
        }
Ejemplo n.º 16
0
        public void Delete(TimeEntryType timeEntryType)
        {
            var session = GetSession();

            try
            {
                session.Transaction.Begin();
                session.Delete(timeEntryType);
                session.Flush();
                session.Transaction.Commit();
            }
            catch (HibernateException ex)
            {
                session.Transaction.Rollback();
                throw new EntityDeleteException("Error deleting TimeEntryType", ex);
            }
        }
        private async void LoadTimeEntries()
        {
            _busyService.ShowBusy(_reportscreenKey);
            List <TimeEntry> timeEntries = null;

            try
            {
                timeEntries = await _timeEntryService.GetTimeEntriesByDate(FromDate, ToDate);
            }
            catch (Exception ex)
            {
                if (!_isShowingTextbox)
                {
                    _isShowingTextbox = true;
                    var result = MessageBox.Show("Error loading timeentries", "Error", MessageBoxButton.OK);
                    _isShowingTextbox = result == MessageBoxResult.None;
                }
                Logger.Error(ex);
            }
            try
            {
                ReportCommands.DataLoaded.Execute(null);
                if (timeEntries != null)
                {
                    var gridRowViewModels = timeEntries.Select(timeEntry =>
                    {
                        TimeEntryType timeEntryType = null;
                        if (TimeEntryTypes != null)
                        {
                            var @default  = TimeEntryTypes.FirstOrDefault(x => x.IsDefault);
                            timeEntryType = timeEntry.TimeEntryType == null
                                                   ? @default
                                                   : TimeEntryTypes.FirstOrDefault(x => x.Id == timeEntry.TimeEntryType.Id);
                        }
                        return(new GridRowItemViewModel(timeEntry, timeEntryType));
                    });
                    GridRows = new ObservableCollection <GridRowItemViewModel>(gridRowViewModels);
                }
            }
            catch (Exception ex)
            {
                Logger.Error(ex);
            }

            _busyService.HideBusy(_reportscreenKey);
        }
Ejemplo n.º 18
0
        public void AddTimeEntryType(TimeEntryType timeEntryType)
        {
            lock (LockObj)
            {
                if (DataSet.TimeEntryTypes.SingleOrDefault(t => timeEntryType.Id == t.Id) == null)
                {
                    var newRow = DataSet.TimeEntryTypes.NewTimeEntryTypesRow();
                    newRow.Id   = timeEntryType.Id;
                    newRow.Name = timeEntryType.Name;
                    newRow.IsBillableByDefault = timeEntryType.IsBillableByDefault;
                    newRow.IsDefault           = timeEntryType.IsDefault;
                    if (timeEntryType.CustomerId.HasValue)
                    {
                        newRow.CustomerId = timeEntryType.CustomerId.Value;
                    }

                    DataSet.TimeEntryTypes.AddTimeEntryTypesRow(newRow);
                    Save();
                }
            }
        }
Ejemplo n.º 19
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));
        }
Ejemplo n.º 20
0
 public TimeEntry Create(User user, Task task, TimeEntryType timeEntryType, DateTime startTime, DateTime endTime, string description, double timeSpent, double pauseTime, double billableTime,
                         bool billable, double price)
 {
     return(Create(Guid.NewGuid(), user, task, timeEntryType, startTime, endTime, description, timeSpent, pauseTime,
                   billableTime, billable, price));
 }
Ejemplo n.º 21
0
 public IObservable <TimeEntryType> SaveTimeEntryType(TimeEntryType timeEntryType)
 {
     return(_saveTimeEntryType(timeEntryType).ObserveOnDispatcher());
 }
Ejemplo n.º 22
0
 private void Add(TimeEntryType timeEntryType)
 {
     _dataWrapper.AddTimeEntryType(timeEntryType);
 }
Ejemplo n.º 23
0
 public TimeEntryTypeViewModel(TimeEntryType timeEntryType)
 {
     TimeEntryType = timeEntryType;
 }
Ejemplo n.º 24
0
 private static TimeEntry Create(Common.DataTransferObjects.TimeEntryDto timeEntryDto, Core.Model.Task task, TimeEntryType timeEntryType)
 {
     return(TimeEntry.Create(timeEntryDto.Guid,
                             task,
                             timeEntryType,
                             TimeSpan.FromHours(timeEntryDto.TimeSpent),
                             TimeSpan.FromHours(timeEntryDto.BillableTime),
                             timeEntryDto.Description,
                             timeEntryDto.StartTime,
                             timeEntryDto.EndTime,
                             timeEntryDto.PricePrHour,
                             true,
                             string.Empty,
                             timeEntryDto.Billable,
                             new TimeEntryHistory(),
                             true,
                             timeEntryDto.CreateDate,
                             timeEntryDto.ClientSourceId,
                             timeEntryDto.Invoiced));
 }
Ejemplo n.º 25
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));
 }
Ejemplo n.º 26
0
 private static TimeEntryType CreateTimeEntryType(TimeTrackerDataSet.TimeEntryTypesRow row, int?companyId = null)
 {
     return(TimeEntryType.Create(row.Id, row.IsDefault, row.IsBillableByDefault, row.Name, companyId));
 }
 public UserWLanTimeEntryTypeItemViewmodel(TimeEntryType timeEntryTypes, IUserWLanTimeEntryType userWLanTimeEntryType)
 {
     UserWLanTimeEntryType = userWLanTimeEntryType;
     _timeEntryTypes       = timeEntryTypes;
 }
 private void SetAsDefault(TimeEntryType timeEntryType)
 {
     TimeEntryTypes.ToList().ForEach(t => t.IsDefault = false);
     timeEntryType.IsDefault = true;
 }
Ejemplo n.º 29
0
 public TimeEntry(DateTime time, TimeEntryType type)
 {
     this.Time = time;
     this.Type = type;
 }
Ejemplo n.º 30
0
 public TimeEntryTypeSaveEventArgs(TimeEntryType timeEntryType)
 {
     TimeEntryType = timeEntryType;
 }