Ejemplo n.º 1
0
 public PartialViewResult _AddParents(CreateParentsOverview model)
 {
     if (ModelState.IsValid)
     {
         return(PartialView("_AddChild"));
     }
     return(PartialView(model));
 }
Ejemplo n.º 2
0
        /**PARENTS****************************/
        // GET: Administration/Children/Parents
        public PartialViewResult _AddParents()
        {
            CreateParentsOverview cvo = new CreateParentsOverview();

            cvo.relationLinks = GetRelationLinksOfCurrentToddler();
            cvo.parents       = GetParentsOfCurrentToddler();
            cvo.parent        = new Parent();

            return(PartialView(cvo));
        }
Ejemplo n.º 3
0
        public PartialViewResult CreateParent(CreateParentsOverview model)
        {
            if (ModelState.IsValid)
            {
                Toddler toddler = GetCurrentToddler();
                Parent  parent  = new Parent();

                parent.Person                  = new Person();
                parent.Person.FirstName        = model.parent.Person.FirstName;
                parent.Person.LastName         = model.parent.Person.LastName;
                parent.Person.Gender           = model.parent.Person.Gender;
                parent.Person.BirthDate        = model.parent.Person.BirthDate;
                parent.Person.RegistrationDate = DateTime.Now;
                parent.Person.Active           = false;

                parent.Person.Address            = new Address();
                parent.Person.Address.City       = model.parent.Person.Address.City;
                parent.Person.Address.PostalCode = model.parent.Person.Address.PostalCode;
                parent.Person.Address.Street     = model.parent.Person.Address.Street;
                parent.Person.Address.Number     = model.parent.Person.Address.Number;
                parent.Person.Address.Bus        = model.parent.Person.Address.Bus;

                parent.Person.ContactDetail           = new ContactDetail();
                parent.Person.ContactDetail.HomePhone = model.parent.Person.ContactDetail.HomePhone;
                parent.Person.ContactDetail.CellPhone = model.parent.Person.ContactDetail.CellPhone;
                parent.Person.ContactDetail.WorkPhone = model.parent.Person.ContactDetail.WorkPhone;
                parent.Person.ContactDetail.Email     = model.parent.Person.ContactDetail.Email;

                db.Parents.Add(parent);
                db.SaveChanges();

                RelationLink relationLink = new RelationLink();
                relationLink.Person          = db.Persons.Find(parent.PersonId);
                relationLink.Toddler         = toddler;
                relationLink.RelationToChild = "isParent";

                db.RelationLinks.Add(relationLink);
                db.SaveChanges();
            }
            return(PartialView("_ListParents", GetParentsOfCurrentToddler()));
        }