public ActionResult Create(School school)
 {
     var dto = new SchoolDto()
         {
             Name = school.Name
         };
     _schoolRepo.Save(dto);
     return RedirectToAction("Index");
 }
        private StudentPackage getStudentFromRow(XElement row)
        {
            var pkg = new StudentPackage();
            var elements = row.Elements("td");
            var arr = elements.ToArray();
            var s = new StudentDto();
            s.FirstName = arr[0].Value;
            s.LastName = arr[1].Value;
            s.AmountFromWebsite = arr[5].Value.CastToDecimal();
            s.Address1 = arr[8].Value;
            s.Address2 = arr[9].Value;
            s.City = arr[10].Value;
            s.State = arr[11].Value;
            s.Zip = arr[12].Value;
            s.Phone = arr[13].Value;
            var school = new SchoolDto() {Name = correctSchoolName(arr[14].Value)};
            var teacher = new ContactDto() { LastName = arr[15].Value, Title = "Teacher" };

            s.Grade = arr[16].Value;
            pkg.school = school;
            pkg.teacher = teacher;
            pkg.student = s;
            return pkg;
        }
Example #3
0
 private static IEnumerable<Contact> getContacts(SchoolDto parent, IList<ContactDto> contacts, bool LazyLoad)
 {
     return LazyLoad ? null : contacts.Select(c => c.MapToModel(parent));
 }
Example #4
0
 public static Contact MapToModel(this ContactDto contact, SchoolDto parent)
 {
     return new Contact
         {
             Title = contact.Title,
             FirstName = contact.FirstName,
             LastName = contact.LastName,
             Id = contact.Id,
             School = parent.Name,
             SchoolId = parent.Id
         };
 }
 public void Save(SchoolDto school)
 {
     _session.Save(school);
 }
 public void Expel(SchoolDto school)
 {
     _session.Evict(school);
 }
 public void AddContact(SchoolDto school, ContactDto contactDto)
 {
     contactDto.Id =  (long) _session.Save(contactDto);
     school.Contacts.Add(contactDto);
     _session.Flush();
 }