示例#1
0
 public ActivityViewModel(ActivityDto activity, IHrService service, ILoadeableViewModel parentVm)
     : base(activity)
 {
     this.ParentVm = parentVm;
     this.Service = service;
     this.deleteActivityCommand = new RelayCommand(DeleteActivity, CanDeleteActivity);
 }
        public ActivityCardViewModel(ActivityDto activity)
        {
            if (activity == null) { throw new ArgumentNullException("activity"); }
            else if (activity.People == null) { throw new ArgumentNullException("activity.People"); }

            this.Activity = activity;

            var beneficiaries = activity.People.GetBeneficiaries();
            Beneficiaries = new ObservableCollection<PersonDto>(beneficiaries);
            HasBeneficiaries = Beneficiaries.Count > 0;
            Beneficiaries.CollectionChanged += (s, e) => this.HasBeneficiaries = Beneficiaries.Count > 0;

            var educators = activity.People.GetEducators();
            Educators = new ObservableCollection<PersonDto>(educators);

            Name = Activity.Name;
            MomentDay = Activity.MomentDay;
            DayOfWeek = Activity.DayOfWeek;
        }
示例#3
0
        public void UpdateActivity(ActivityDto activity)
        {
            using (var db = new DataContext())
            {
                var toRemove = db.Activities.Find(activity.Id);
                db.Activities.Remove(toRemove);

                var ePeople = new List<Person>();
                var toAdd = activity.ToEntity();

                foreach (var p in activity.People) { ePeople.Add(db.People.Find(p.Id)); }
                toAdd.People = ePeople;
                db.Activities.Add(toAdd);

                db.SaveChanges();
            }
        }
示例#4
0
 public void CreateActivity(ActivityDto activity)
 {
     this.CreateActivity(activity.DayOfWeek, activity.MomentDay, activity.People, activity.Name);
 }
示例#5
0
 public void RemoveActivity(ActivityDto activity)
 {
     this.RemoveActivity(activity.Id);
 }