public IHttpActionResult AddPerson(ServicePersonData servicePersonData)
        {
            string retVal = "";

            var personSearch = new PersonSearch(new Security(new WebUser()));

            var servicePerson = servicePersonData.servicePersonAdd.AsServicePerson();

            try
            {
                personSearch.Save(servicePerson, servicePersonData.sources.ParseToGuidList(), new PersonValidator(servicePerson));
            }
            catch (Exception ex1)
            {
                retVal = ex1.Message;
            }

            if (retVal != "")
            {
                return Content(HttpStatusCode.BadRequest, retVal);
            }

            return Ok(servicePerson.PersonId);
        }
예제 #2
0
        public string AddPerson(string personId, string birthparishId, string deathparishId, string referenceparishId, string sources, string christianName, string surname, string fatherchristianname,
            string fathersurname, string motherchristianname, string mothersurname,
            string source, string ismale, string occupation, string datebirthstr,
            string datebapstr, string birthloc, string birthcounty, string datedeath,
            string deathloc, string deathcounty, string notes, string refdate,
            string refloc, string fatheroccupation, string spousesurname, string spousechristianname, string years, string months, string weeks, string days)
        {
            string retVal = "";

            WebHelper.WriteParams(birthparishId, deathparishId, referenceparishId, sources, christianName, surname, fatherchristianname,
             fathersurname, motherchristianname, mothersurname,
             source, ismale, occupation, datebirthstr,
             datebapstr, birthloc, birthcounty, datedeath,
             deathloc, deathcounty, notes, refdate,
             refloc, fatheroccupation, spousesurname, spousechristianname, years, months, weeks, days);

              var iModel = new PersonSearch(new Security(new WebUser()));

            datebirthstr = DateTools.MakeDateString(datebapstr, datebirthstr, datedeath, years, months, weeks, days);

            var sp = new ServicePerson
                {
                    PersonId = personId.ToGuid(),
                    ChristianName = christianName,
                    Surname = surname,
                    FatherChristianName = fatherchristianname,
                    FatherSurname = fathersurname,
                    MotherChristianName = motherchristianname,
                    MotherSurname = mothersurname,
                    IsMale = ismale,
                    Occupation = occupation,
                    Birth = datebirthstr,
                    Baptism = datebapstr,
                    Death = datedeath,
                    BirthLocation = birthloc,
                    DeathLocation = deathloc,
                    BirthCounty = birthcounty,
                    DeathCounty = deathcounty,
                    Notes = notes,
                    ReferenceDate = refdate,
                    FatherOccupation = fatheroccupation,
                    SpouseChristianName = spousechristianname,
                    SpouseSurname = spousesurname,
                    ReferenceLocation = refloc,
                    BirthLocationId = birthparishId,
                    ReferenceLocationId = referenceparishId,
                    DeathLocationId = deathparishId,
                    SourceDescription = source,
                    BirthYear = datebirthstr.ParseToValidYear(),//DateTools.GetDateYear(datebirthstr),
                    BaptismYear =datebapstr.ParseToValidYear(),// DateTools.GetDateYear(),
                    DeathYear =datedeath.ParseToValidYear()// DateTools.GetDateYear(datedeath)
                };

            try
            {
                iModel.Save(sp,sources.ParseToGuidList(),new PersonValidator(sp));
            }
            catch (Exception ex1)
            {
                retVal = ex1.Message;
            }

            return WebHelper.MakeReturn(sp.PersonId.ToString(), retVal);
        }