示例#1
0
        public void DeleteActivity(MappedActivity activity)
        {
            Activity act = ActivityMapper.MapActivityToDB(activity);

            context.Acivities.Attach(act);
            context.Acivities.Remove(act);
            context.SaveChanges();
        }
示例#2
0
        public MappedActivity ModifActivity(MappedActivity activity)
        {
            Activity act = ActivityMapper.MapActivityToDB(activity);

            context.Entry(act).State = EntityState.Modified;
            context.SaveChanges();

            act = context.Acivities.SingleOrDefault(a => a.ID == activity.ID);
            return(ActivityMapper.MapActivityFromDB(act));
        }
示例#3
0
        public MappedActivity AddActivity(MappedActivity activity)
        {
            Activity act = ActivityMapper.MapActivityToDB(activity);

            act.CreatedTime = DateTime.Now;
            act             = context.Acivities.Add(act).Entity;
            context.SaveChanges();

            return(ActivityMapper.MapActivityFromDB(act));
        }
示例#4
0
        private void AddNewActivity(object sender, TappedRoutedEventArgs e)
        {
            if (Validation())
            {
                MappedActivity activity = new MappedActivity()
                {
                    Name     = NameTextBox.Text,
                    WorkTime = Int32.Parse(WorkTimeTextBox.Text),
                    RestTime = Int32.Parse(RestTimeTextBox.Text),
                    Color    = _color.Value
                };

                _service.AddActivity(activity);
                _parent.RefreshActivityList();
                ClosePopup();
            }
        }
示例#5
0
        public static MappedActivity MapActivityFromDB(Activity activity)
        {
            MappedActivity mapped = new MappedActivity()
            {
                ID               = activity.ID,
                CreatedTime      = activity.CreatedTime,
                Name             = activity.Name,
                WorkTime         = activity.WorkTime,
                RestTime         = activity.RestTime,
                EllapsedWorkTime = activity.EllapsedWorkTime,
                EllapsedRestTime = activity.EllapsedRestTime,
                EllapsedMinutes  = activity.EllapsedMinutes,
                Color            = GetSolidColorBrush(activity.Color).Color
            };

            return(mapped);
        }
示例#6
0
        public static Activity MapActivityToDB(MappedActivity mActivity)
        {
            Activity activity = new Activity()
            {
                ID               = mActivity.ID,
                CreatedTime      = mActivity.CreatedTime,
                Name             = mActivity.Name,
                WorkTime         = mActivity.WorkTime,
                RestTime         = mActivity.RestTime,
                EllapsedWorkTime = mActivity.EllapsedWorkTime,
                EllapsedRestTime = mActivity.EllapsedRestTime,
                EllapsedMinutes  = mActivity.EllapsedMinutes,
                Color            = mActivity.Color.ToHex()
            };

            return(activity);
        }
示例#7
0
        private void ActivityListView_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            MappedActivity selectedActivity = (MappedActivity)(sender as ListView).SelectedItem;

            if (selectedActivity != null)
            {
                MainGrid.Background         = new SolidColorBrush(selectedActivity.Color);
                ActivityNameHeader.Text     = selectedActivity.Name;
                _viewModel.SelectedActivity = selectedActivity;


                MinuteTextBlock.Text = _viewModel.SelectedActivity.WorkTime.ToString();
                SecondTextBlock.Text = "00";
                RefreshEllapseLabels();
                _isActiveStatus     = true;
                StartButton.Content = "Start!";
            }
        }