Esempio n. 1
0
        /// <summary>
        /// Crea un perfil en base al modelo recibido, considerando únicamente los hijos del primer nivel.
        /// </summary>
        /// <param name="profile"></param>
        /// <returns></returns>
        public ResultBM CreateProfile(ProfileBM profile)
        {
            try
            {
                log.AddLogInfo("Creando perfil", "Creando perfil.", this);
                ProfileDAL profileDal    = new ProfileDAL();
                ResultBM   isValidResult = IsValid(profile);

                if (!isValidResult.IsValid())
                {
                    return(isValidResult);
                }

                //Se agrega el root
                PermissionDTO root = new PermissionDTO(profile.fatherCode, profile.code, profile.Description);
                profileDal.SaveProfile(root);
                CreateRelation(profile);

                log.AddLogInfo("Creando perfil", "El perfil se ha creado exitosamente.", this);
                return(new ResultBM(ResultBM.Type.OK, "Perfil creado: " + profile.Description));
            }
            catch (Exception exception)
            {
                log.AddLogCritical("Recuperando perfil", exception.Message, this);
                return(new ResultBM(ResultBM.Type.EXCEPTION, SessionHelper.GetTranslation("SAVING_ERROR") + " " + exception.Message, exception));
            }
        }