public DisplayGroupViewModel(GroupDto group, IEnumerable<PersonDto> morning, IEnumerable<PersonDto> afternoon) { this.GroupName = group.Name; this.GroupOrder = group.Order; this.EducatorsMorning = new ObservableCollection<PersonDto>(morning); this.EducatorsAfternoon = new ObservableCollection<PersonDto>(afternoon); }
public DisplayOneDayGroupViewModel(IScheduleService srv , DateTime curentDate , GroupDto group , IEnumerable<PersonDto> morning , IEnumerable<PersonDto> afternoon) { this.CurrentDate = curentDate; this.Service = srv; this.Group = group; this.EducatorsMorning = new ObservableCollection<PersonDto>(morning); this.EducatorsAfternoon = new ObservableCollection<PersonDto>(afternoon); this.BeneficiariesMorning = new ObservableCollection<PersonDto>(); this.BeneficiariesAfternoon = new ObservableCollection<PersonDto>(); }
public void UpdateGroup(GroupDto @group) { using (var db = new DataContext()) { var eGroup = (from g in db.Groups.Include(e => e.People) where g.Id == @group.Id select g).FirstOrDefault(); if (eGroup == null) { throw new EntityNotFountException(); } while (eGroup.People.Count() > 0) { eGroup.People.RemoveAt(0); } var benefs = new List<Person>(); foreach (var benef in group.People) { var b = db.People.Find(benef.Id); eGroup.People.Add(b); } eGroup.Name = group.Name; eGroup.Order = group.Order; db.SaveChanges(); } }
public void CreateGroup(GroupDto group) { group.Name = group.Name.ToLower(); using (var db = new DataContext()) { var exist = (from g in db.Groups where g.Name.ToLower() == @group.Name select g).Count() > 0; if (exist) { throw new EntityAlreadyExistException(); } db.Groups.Add(group.ToEntity()); db.SaveChanges(); } }
public void RemoveGroup(GroupDto group) { this.RemoveGroup(group.Id); }