public void DeleteActivity(MappedActivity activity) { Activity act = ActivityMapper.MapActivityToDB(activity); context.Acivities.Attach(act); context.Acivities.Remove(act); context.SaveChanges(); }
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)); }
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)); }
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(); } }
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); }
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); }
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!"; } }