public Result InsStudentPerson(IDictionary <string, object> dataSections)
        {
            var result = new Result();

            using (var transaction = new TransactionScope())
            {
                var person = dataSections["InsPerson"] as Person;


                var getPersonByDocument = _personDAOService.GetPersonByDocument(person);
                if (!getPersonByDocument.Success)
                {
                    var insPerson = _personDAOService.InsPerson(person);
                    if (!insPerson.Success)
                    {
                        result.Message = insPerson.Message;
                        return(result);
                    }
                    person.Id = insPerson.Data.Id;
                }
                else
                {
                    person.Id = getPersonByDocument.Data.Id;
                    var getStudentByPersonId = _studentDAOService.GetStudentByPersonId(person.Id);
                    if (getStudentByPersonId.Success)
                    {
                        result.Message = "Esta persona ya se encuenta registrada como estudiante";
                        return(result);
                    }

                    var updPerson = _personDAOService.UpdPerson(person);
                    if (!updPerson.Success)
                    {
                        result.Message = updPerson.Message;
                        return(result);
                    }
                }

                var student = dataSections["InsStudent"] as Student;
                student.PersonId = person.Id;

                var updStudent = _studentDAOService.InsStudent(student);
                if (!updStudent.Success)
                {
                    result.Message = updStudent.Message;
                    return(result);
                }
                transaction.Complete();
            }
            result.Success = true;
            result.Message = "se ha actualizado correctacmente el estudiante.";
            return(result);
        }
Exemple #2
0
        public ActionResult InsPerson(Person person)
        {
            var insPerson = _personService.InsPerson(person);

            return(new JsonResult(insPerson));
        }