コード例 #1
0
 public GridRowItemViewModel(TimeEntry timeEntry, TimeEntryType timeEntryType)
 {
     TimeEntry        = timeEntry;
     EditableType     = timeEntryType;
     EditableBillable = TimeEntry.Billable;
     HasChanges       = false;
 }
コード例 #2
0
        //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();
            }
        }
コード例 #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);
                }
            }
        }
コード例 #4
0
        public EditTimeEntryTypeViewModel(IDataService dataService, TimeEntryType timeEntryType)
        {
            _timeEntryType = timeEntryType;

            _dataService      = dataService;
            SaveTimeEntryType = new DelegateCommand <object>(ExecuteSaveTimeEntryType, CanSaveTimeEntryType);
        }
コード例 #5
0
        private void EditTimeEntryTypeStart(TimeEntryType timeEntryType)
        {
            var editTimeEntryTypeView      = new EditTimeEntryTypeView();
            var editTimeEntryTypeViewModel = new EditTimeEntryTypeViewModel(_dataService, timeEntryType);

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

            return(timeEntryType);
        }
コード例 #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
     });
 }
コード例 #10
0
ファイル: Service.svc.cs プロジェクト: StefanAniff/hb.trex
 public TimeEntryType SaveTimeEntryType(TimeEntryType timeEntryType)
 {
     try
     {
         return(_timeEntryService.SaveTimeEntryType(timeEntryType));
     }
     catch (Exception ex)
     {
         LogError(ex);
         return(null);
     }
 }
コード例 #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);
        }
コード例 #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));
        }
コード例 #13
0
        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());
        }
コード例 #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();
        }
コード例 #15
0
ファイル: DtoExtensions.cs プロジェクト: StefanAniff/hb.trex
        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);
        }
コード例 #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);
            }
        }
コード例 #17
0
        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);
        }
コード例 #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();
                }
            }
        }
コード例 #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));
        }
コード例 #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));
 }
コード例 #21
0
ファイル: DataService.cs プロジェクト: StefanAniff/hb.trex
 public IObservable <TimeEntryType> SaveTimeEntryType(TimeEntryType timeEntryType)
 {
     return(_saveTimeEntryType(timeEntryType).ObserveOnDispatcher());
 }
コード例 #22
0
 private void Add(TimeEntryType timeEntryType)
 {
     _dataWrapper.AddTimeEntryType(timeEntryType);
 }
コード例 #23
0
 public TimeEntryTypeViewModel(TimeEntryType timeEntryType)
 {
     TimeEntryType = timeEntryType;
 }
コード例 #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));
 }
コード例 #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));
 }
コード例 #26
0
 private static TimeEntryType CreateTimeEntryType(TimeTrackerDataSet.TimeEntryTypesRow row, int?companyId = null)
 {
     return(TimeEntryType.Create(row.Id, row.IsDefault, row.IsBillableByDefault, row.Name, companyId));
 }
コード例 #27
0
 public UserWLanTimeEntryTypeItemViewmodel(TimeEntryType timeEntryTypes, IUserWLanTimeEntryType userWLanTimeEntryType)
 {
     UserWLanTimeEntryType = userWLanTimeEntryType;
     _timeEntryTypes       = timeEntryTypes;
 }
コード例 #28
0
 private void SetAsDefault(TimeEntryType timeEntryType)
 {
     TimeEntryTypes.ToList().ForEach(t => t.IsDefault = false);
     timeEntryType.IsDefault = true;
 }
コード例 #29
0
ファイル: TimeEntry.cs プロジェクト: rywem/MyTimeclock
 public TimeEntry(DateTime time, TimeEntryType type)
 {
     this.Time = time;
     this.Type = type;
 }
コード例 #30
0
 public TimeEntryTypeSaveEventArgs(TimeEntryType timeEntryType)
 {
     TimeEntryType = timeEntryType;
 }