コード例 #1
0
        private void Child_Update()
        {
            if (!IsDirty)
            {
                return;
            }

            SimpleAuditTrail();
            var dto = new VendorItemDto();

            dto.VendorId        = VendorId;
            dto.VendorName      = VendorName;
            dto.VendorContact   = VendorContact;
            dto.VendorPhone     = VendorPhone;
            dto.VendorEmail     = VendorEmail;
            dto.IsPrimaryVendor = IsPrimaryVendor;
            dto.LastUpdated     = LastUpdated;
            using (var dalManager = DalFactoryProjectsVendors.GetManager())
            {
                var args = new DataPortalHookArgs(dto);
                OnUpdatePre(args);
                var dal = dalManager.GetProvider <IVendorItemDal>();
                using (BypassPropertyChecks)
                {
                    var resultDto = dal.Update(dto);
                    args = new DataPortalHookArgs(resultDto);
                }
                OnUpdatePost(args);
            }
        }
コード例 #2
0
        private void Child_Insert(ProjectEdit parent)
        {
            SimpleAuditTrail();
            var dto = new VendorItemDto();

            dto.Parent_ProjectId = parent.ProjectId;
            dto.VendorName       = VendorName;
            dto.VendorContact    = VendorContact;
            dto.VendorPhone      = VendorPhone;
            dto.VendorEmail      = VendorEmail;
            dto.IsPrimaryVendor  = IsPrimaryVendor;
            dto.LastUpdated      = LastUpdated;
            using (var dalManager = DalFactoryProjectsVendors.GetManager())
            {
                var args = new DataPortalHookArgs(dto);
                OnInsertPre(args);
                var dal = dalManager.GetProvider <IVendorItemDal>();
                using (BypassPropertyChecks)
                {
                    var resultDto = dal.Insert(dto);
                    LoadProperty(VendorIdProperty, resultDto.VendorId);
                    args = new DataPortalHookArgs(resultDto);
                }
                OnInsertPost(args);
            }
        }
コード例 #3
0
        private VendorItemDto Fetch(SafeDataReader dr)
        {
            var vendorItem = new VendorItemDto();

            // Value properties
            vendorItem.VendorId        = dr.GetInt32("VendorId");
            vendorItem.VendorName      = dr.GetString("VendorName");
            vendorItem.VendorContact   = dr.GetString("VendorContact");
            vendorItem.VendorPhone     = dr.GetString("VendorPhone");
            vendorItem.VendorEmail     = dr.GetString("VendorEmail");
            vendorItem.IsPrimaryVendor = dr.GetBoolean("IsPrimaryVendor");
            vendorItem.LastUpdated     = dr.GetSmartDate("LastUpdated", true);

            return(vendorItem);
        }
コード例 #4
0
        /// <summary>
        /// Loads a <see cref="VendorItem"/> object from the given <see cref="VendorItemDto"/>.
        /// </summary>
        /// <param name="data">The VendorItemDto to use.</param>
        private void Child_Fetch(VendorItemDto data)
        {
            // Value properties
            LoadProperty(VendorIdProperty, data.VendorId);
            LoadProperty(VendorNameProperty, data.VendorName);
            LoadProperty(VendorContactProperty, data.VendorContact);
            LoadProperty(VendorPhoneProperty, data.VendorPhone);
            LoadProperty(VendorEmailProperty, data.VendorEmail);
            LoadProperty(IsPrimaryVendorProperty, data.IsPrimaryVendor);
            LoadProperty(LastUpdatedProperty, data.LastUpdated);
            var args = new DataPortalHookArgs(data);

            OnFetchRead(args);
            // check all object rules and property rules
            BusinessRules.CheckRules();
        }
コード例 #5
0
 /// <summary>
 /// Inserts a new VendorItem object in the database.
 /// </summary>
 /// <param name="vendorItem">The Vendor Item DTO.</param>
 /// <returns>The new <see cref="VendorItemDto"/>.</returns>
 public VendorItemDto Insert(VendorItemDto vendorItem)
 {
     using (var ctx = ConnectionManager <SqlConnection> .GetManager("ProjectsVendors"))
     {
         using (var cmd = new SqlCommand("dbo.AddVendorItem", ctx.Connection))
         {
             cmd.CommandType = CommandType.StoredProcedure;
             cmd.Parameters.AddWithValue("@ProjectId", vendorItem.Parent_ProjectId).DbType      = DbType.Int32;
             cmd.Parameters.AddWithValue("@VendorId", vendorItem.VendorId).Direction            = ParameterDirection.Output;
             cmd.Parameters.AddWithValue("@VendorName", vendorItem.VendorName).DbType           = DbType.String;
             cmd.Parameters.AddWithValue("@VendorContact", vendorItem.VendorContact).DbType     = DbType.String;
             cmd.Parameters.AddWithValue("@VendorPhone", vendorItem.VendorPhone).DbType         = DbType.String;
             cmd.Parameters.AddWithValue("@VendorEmail", vendorItem.VendorEmail).DbType         = DbType.String;
             cmd.Parameters.AddWithValue("@IsPrimaryVendor", vendorItem.IsPrimaryVendor).DbType = DbType.Boolean;
             cmd.Parameters.AddWithValue("@LastUpdated", vendorItem.LastUpdated.DBValue).DbType = DbType.DateTime2;
             cmd.ExecuteNonQuery();
             vendorItem.VendorId = (int)cmd.Parameters["@VendorId"].Value;
         }
     }
     return(vendorItem);
 }
コード例 #6
0
 /// <summary>
 /// Updates in the database all changes made to the VendorItem object.
 /// </summary>
 /// <param name="vendorItem">The Vendor Item DTO.</param>
 /// <returns>The updated <see cref="VendorItemDto"/>.</returns>
 public VendorItemDto Update(VendorItemDto vendorItem)
 {
     using (var ctx = ConnectionManager <SqlConnection> .GetManager("ProjectsVendors"))
     {
         using (var cmd = new SqlCommand("dbo.UpdateVendorItem", ctx.Connection))
         {
             cmd.CommandType = CommandType.StoredProcedure;
             cmd.Parameters.AddWithValue("@VendorId", vendorItem.VendorId).DbType               = DbType.Int32;
             cmd.Parameters.AddWithValue("@VendorName", vendorItem.VendorName).DbType           = DbType.String;
             cmd.Parameters.AddWithValue("@VendorContact", vendorItem.VendorContact).DbType     = DbType.String;
             cmd.Parameters.AddWithValue("@VendorPhone", vendorItem.VendorPhone).DbType         = DbType.String;
             cmd.Parameters.AddWithValue("@VendorEmail", vendorItem.VendorEmail).DbType         = DbType.String;
             cmd.Parameters.AddWithValue("@IsPrimaryVendor", vendorItem.IsPrimaryVendor).DbType = DbType.Boolean;
             cmd.Parameters.AddWithValue("@LastUpdated", vendorItem.LastUpdated.DBValue).DbType = DbType.DateTime2;
             var rowsAffected = cmd.ExecuteNonQuery();
             if (rowsAffected == 0)
             {
                 throw new DataNotFoundException("VendorItem");
             }
         }
     }
     return(vendorItem);
 }