Exemplo n.º 1
0
        /// <summary>
        /// Crea una persona.
        /// </summary>
        /// <param name="personBm"></param>
        /// <returns></returns>
        public ResultBM SavePerson(PersonBM personBm)
        {
            try
            {
                AddressBLL addressBll = new AddressBLL();
                ResultBM   addressResult;
                PersonDAL  personDal = new PersonDAL();
                PersonDTO  personDto;
                ResultBM   validationResult;

                validationResult = IsValid(personBm);
                if (!validationResult.IsValid())
                {
                    return(validationResult);
                }

                addressResult = addressBll.SaveAddress(personBm.address);
                if (!addressResult.IsValid())
                {
                    return(addressResult);
                }

                personDto = new PersonDTO(personBm.id, personBm.name, personBm.lastName, personBm.Birthdate, personBm.Email, personBm.phone, personBm.gender, personBm.dni, personBm.address.id);
                personDal.SavePerson(personDto);
                personBm.id = personDto.id;

                return(new ResultBM(ResultBM.Type.OK, "Se ha creado la persona con el nombre " + personBm.name + " " + personBm.lastName + ".", personBm));
            }
            catch (Exception exception)
            {
                return(new ResultBM(ResultBM.Type.EXCEPTION, SessionHelper.GetTranslation("SAVING_ERROR") + " " + exception.Message, exception));
            }
        }
        public int SavePerson(PersonModel person)
        {
            int       personId = 0;
            PersonDAL dal      = new PersonDAL();

            personId = dal.SavePerson(person);
            return(personId);
        }