public ActionResult GetPersonalData(int PersonID) { PersonGeneral person = mappingController.personListData.personList.Find(item => item.ID == PersonID); if (person != null) { person.Load(); if (person is Person) { return(Json(person as Person)); } else if (person is Company) { return(Json(person as Company)); } else { return(Json("")); } } else { return(Json("")); } }
public PageData ConstructPersonData(int ID) { PersonGeneral person = personListData.personList.Find(item => item.ID == ID); if (person != null) { person.Load(); if (person is Person) { PersonData data = new PersonData(person as Person); data.catalog = personListData.catalog; return(data); } else if (person is Company) { CompanyData data = new CompanyData(person as Company); data.catalog = personListData.catalog; return(data); } else { throw new NotImplementedException("Unhandled person type"); } } else { throw new ArgumentException("Person with current id can not be found"); } }
public ActionResult DeleteContact(int PersonID, int id) { PersonGeneral person = mappingController.personListData.personList.Find(item => item.ID == PersonID); if (person != null) { person.Load(); Contact contact = person.ContactList.Find((item) => { return(item.ID == id); }); if (contact != null) { contact.Delete(); } } return(Json("")); }
public ActionResult DeleteViza(int PersonID, int ID) { PersonGeneral person = mappingController.personListData.personList.Find(item => item.ID == PersonID); if ((person != null) && (person is Person)) { person.Load(); Viza viza = (person as Person).PassportList.FindViza(item => item.ID == ID); if (viza != null) { viza.Delete(); } } return(Json("")); }
public ActionResult DeletePassport(int PersonID, int id) { PersonGeneral person = mappingController.personListData.personList.Find(item => item.ID == PersonID); if ((person != null) && (person is Person)) { person.Load(); Passport passport = (person as Person).PassportList.Find((item) => { return(item.ID == id); }); if (passport != null) { passport.Delete(); } } return(Json("")); }
public ActionResult SaveVizaDetails(int PersonID, int ID, string DateApprovedStr, string ValidFromStr, string ValidTillStr, string TargetName, string CountryOfEmmitationName, string Number, string VizaType, int EntriesNumber, int DaysCount, int DaysUsed, string Description, string PassportSerial) { PersonGeneral person = mappingController.personListData.personList.Find(item => item.ID == PersonID); if ((person != null) && (person is Person)) { person.Load(); Passport passport = (person as Person).PassportList.Find(item => item.SerialNumber == PassportSerial); if (passport != null) { Viza viza = (person as Person).PassportList.FindViza(item => item.ID == ID); if (viza == null) { viza = passport.vizaList.Create(); } viza.PassportID = passport.ID; viza.DateApprovedStr = DateApprovedStr; viza.ValidFromStr = ValidFromStr; viza.ValidTillStr = ValidTillStr; viza.TargetName = TargetName; Country countryOfEmmitation = mappingController.personListData.catalog.countryList.Find(item => item.Name == CountryOfEmmitationName); if (countryOfEmmitation != null) { viza.CountryOfEmmitationID = countryOfEmmitation.ID; } viza.Number = Number; viza.VizaType = VizaType; viza.EntriesNumber = EntriesNumber; viza.DaysCount = DaysCount; viza.DaysUsed = DaysUsed; viza.Description = Description; viza.Save(); } } return(Json("")); }
public ActionResult SavePassport(int PersonID, int id, string passportSerial, string expireDate, string personName, string personSurname, string countryOfEmitation, string countryOfCitizen, string description) { PersonGeneral person = mappingController.personListData.personList.Find(item => item.ID == PersonID); if ((person != null) && (person is Person)) { person.Load(); Passport passport = (person as Person).PassportList.Find((item) => { return(item.ID == id); }); if (passport == null) { passport = (person as Person).PassportList.Create(); } else { passport.Load(); } try { passport.SerialNumber = passportSerial; passport.ValidTillStr = expireDate; passport.PersonName = personName; passport.PersonSurname = personSurname; passport.Description = description; mappingController.settingsData.catalog.countryList.Load(); passport.CountryOfEmmitation = mappingController.settingsData.catalog.countryList.Find(item => item.Name == countryOfEmitation); passport.Citizen = mappingController.settingsData.catalog.countryList.Find(item => item.Name == countryOfCitizen); } catch (FormatException e) { return(Json(e.Message)); } catch (ArgumentNullException e) { return(Json(e.Message)); } passport.Save(); } return(Json("")); }
public ActionResult SaveContact(int PersonID, int id, string content, string description, string contactType) { PersonGeneral person = mappingController.personListData.personList.Find(item => item.ID == PersonID); if (person != null) { person.Load(); Contact contact = person.ContactList.Find((item) => { return(item.ID == id); }); if (contact == null) { contact = person.ContactList.Create(contactType); } else { contact.Load(); } contact.Content = content; contact.Description = description; contact.Save(); } return(Json("")); }