/// <summary>
        /// Factory method. Loads a <see cref="F11_City_ReChild"/> object from the given F11_City_ReChildDto.
        /// </summary>
        /// <param name="data">The <see cref="F11_City_ReChildDto"/>.</param>
        /// <returns>A reference to the fetched <see cref="F11_City_ReChild"/> object.</returns>
        internal static F11_City_ReChild GetF11_City_ReChild(F11_City_ReChildDto data)
        {
            F11_City_ReChild obj = new F11_City_ReChild();

            obj.Fetch(data);
            // check all object rules and property rules
            obj.BusinessRules.CheckRules();
            return(obj);
        }
        /// <summary>
        /// Loads a <see cref="F11_City_ReChild"/> object from the given <see cref="F11_City_ReChildDto"/>.
        /// </summary>
        /// <param name="data">The F11_City_ReChildDto to use.</param>
        private void Fetch(F11_City_ReChildDto data)
        {
            // Value properties
            City_Child_Name = data.City_Child_Name;
            // parent properties
            city_ID2 = data.Parent_City_ID;
            var args = new DataPortalHookArgs(data);

            OnFetchRead(args);
        }
Example #3
0
        private F11_City_ReChildDto FetchF11_City_ReChild(SafeDataReader dr)
        {
            var f11_City_ReChild = new F11_City_ReChildDto();

            // Value properties
            f11_City_ReChild.City_Child_Name = dr.GetString("City_Child_Name");
            // parent properties
            f11_City_ReChild.Parent_City_ID = dr.GetInt32("City_ID2");

            return(f11_City_ReChild);
        }
Example #4
0
        /// <summary>
        /// Factory method. Loads a <see cref="F11_City_ReChild"/> object from the given F11_City_ReChildDto.
        /// </summary>
        /// <param name="data">The <see cref="F11_City_ReChildDto"/>.</param>
        /// <returns>A reference to the fetched <see cref="F11_City_ReChild"/> object.</returns>
        internal static F11_City_ReChild GetF11_City_ReChild(F11_City_ReChildDto data)
        {
            F11_City_ReChild obj = new F11_City_ReChild();

            // show the framework that this is a child object
            obj.MarkAsChild();
            obj.Fetch(data);
            obj.MarkOld();
            // check all object rules and property rules
            obj.BusinessRules.CheckRules();
            return(obj);
        }
Example #5
0
 /// <summary>
 /// Inserts a new F11_City_ReChild object in the database.
 /// </summary>
 /// <param name="f11_City_ReChild">The F11 City Re Child DTO.</param>
 /// <returns>The new <see cref="F11_City_ReChildDto"/>.</returns>
 public F11_City_ReChildDto Insert(F11_City_ReChildDto f11_City_ReChild)
 {
     using (var ctx = ConnectionManager <SqlConnection> .GetManager("DeepLoad"))
     {
         using (var cmd = new SqlCommand("AddF11_City_ReChild", ctx.Connection))
         {
             cmd.CommandType = CommandType.StoredProcedure;
             cmd.Parameters.AddWithValue("@City_ID2", f11_City_ReChild.Parent_City_ID).DbType         = DbType.Int32;
             cmd.Parameters.AddWithValue("@City_Child_Name", f11_City_ReChild.City_Child_Name).DbType = DbType.String;
             cmd.ExecuteNonQuery();
         }
     }
     return(f11_City_ReChild);
 }
Example #6
0
 /// <summary>
 /// Updates in the database all changes made to the F11_City_ReChild object.
 /// </summary>
 /// <param name="f11_City_ReChild">The F11 City Re Child DTO.</param>
 /// <returns>The updated <see cref="F11_City_ReChildDto"/>.</returns>
 public F11_City_ReChildDto Update(F11_City_ReChildDto f11_City_ReChild)
 {
     using (var ctx = ConnectionManager <SqlConnection> .GetManager("DeepLoad"))
     {
         using (var cmd = new SqlCommand("UpdateF11_City_ReChild", ctx.Connection))
         {
             cmd.CommandType = CommandType.StoredProcedure;
             cmd.Parameters.AddWithValue("@City_ID2", f11_City_ReChild.Parent_City_ID).DbType         = DbType.Int32;
             cmd.Parameters.AddWithValue("@City_Child_Name", f11_City_ReChild.City_Child_Name).DbType = DbType.String;
             var rowsAffected = cmd.ExecuteNonQuery();
             if (rowsAffected == 0)
             {
                 throw new DataNotFoundException("F11_City_ReChild");
             }
         }
     }
     return(f11_City_ReChild);
 }
Example #7
0
        private void Child_Insert(F10_City parent)
        {
            var dto = new F11_City_ReChildDto();

            dto.Parent_City_ID  = parent.City_ID;
            dto.City_Child_Name = City_Child_Name;
            using (var dalManager = DalFactoryParentLoadSoftDelete.GetManager())
            {
                var args = new DataPortalHookArgs(dto);
                OnInsertPre(args);
                var dal = dalManager.GetProvider <IF11_City_ReChildDal>();
                using (BypassPropertyChecks)
                {
                    var resultDto = dal.Insert(dto);
                    args = new DataPortalHookArgs(resultDto);
                }
                OnInsertPost(args);
            }
        }