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; }
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(); } }
public void CreateActivity(ActivityDto activity) { this.CreateActivity(activity.DayOfWeek, activity.MomentDay, activity.People, activity.Name); }
public void RemoveActivity(ActivityDto activity) { this.RemoveActivity(activity.Id); }