protected void btnUpload_Click(object sender, EventArgs e)
    {
        using (CsvReader csv = new CsvReader(new StreamReader(fileUpload.FileContent), true))
        {
            int count = 0;
            RefDepartment orderTA = new RefDepartment();
            int fieldCount = csv.FieldCount;
            string[] headers = csv.GetFieldHeaders();

            while (csv.ReadNextRecord())
            {
                string fullAddress = csv["address_line1"] + " " + csv["address_line2"] + csv["address_line3"] + csv["address_line4"] + csv["address_line5"] + csv["address_post_code"];

                PropertyDetail property = new PropertyDetail();
                property.AddressLine1 = csv["address_line1"];
                property.AddressLine2 = csv["address_line2"];
                property.AddressLine3 = csv["address_line3"];
                property.AddressLine4 = csv["address_line4"];
                property.AddressLine5 = csv["address_line5"];
                property.AddressPostCode = csv["address_post_code"];
                property.AddressFull = fullAddress;
                property.CompanySequence = loggedInUserCoId;
                property.CreatedBy = loggedInUserId;
                property.LastAmendedBy = loggedInUserId;
                property.DateCreated = System.DateTime.Now;
                property.DateLastAmended = System.DateTime.Now;
                property.FlgDeleted = false;
                estateAgentDB.PropertyDetails.AddObject(property);
                estateAgentDB.SaveChanges();

                PropertyFieldDepartment propFieldDepartment = new PropertyFieldDepartment();
                propFieldDepartment.CompanySequence = loggedInUserCoId;
                propFieldDepartment.PropertySequence = property.Sequence;
                propFieldDepartment.DepartmentSequence = int.Parse(ddlDepartments.SelectedValue);
                propFieldDepartment.CreatedBy = loggedInUserId;
                propFieldDepartment.LastAmendedBy = loggedInUserId;
                propFieldDepartment.DateCreated = System.DateTime.Now;
                propFieldDepartment.DateLastAmended = System.DateTime.Now;
                property.PropertyFieldDepartments.Add(propFieldDepartment);

                PropertyFieldCategory propFieldCategory = new PropertyFieldCategory();
                propFieldCategory.CompanySequence = loggedInUserCoId;
                propFieldCategory.PropertySequence = property.Sequence;
                propFieldCategory.CategorySequence = int.Parse(ddlCategory.SelectedValue);
                propFieldCategory.CreatedBy = loggedInUserId;
                propFieldCategory.LastAmendedBy = loggedInUserId;
                propFieldCategory.DateCreated = System.DateTime.Now;
                propFieldCategory.DateLastAmended = System.DateTime.Now;
                property.PropertyFieldCategories.Add(propFieldCategory);

                estateAgentDB.SaveChanges();

                count++;
            }

            SetInfoMessage(count + " properties added to the system.");
        }
    }
 /// <summary>
 /// Deprecated Method for adding a new object to the PropertyFieldCategories EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToPropertyFieldCategories(PropertyFieldCategory propertyFieldCategory)
 {
     base.AddObject("PropertyFieldCategories", propertyFieldCategory);
 }
 /// <summary>
 /// Create a new PropertyFieldCategory object.
 /// </summary>
 /// <param name="sequence">Initial value of the Sequence property.</param>
 public static PropertyFieldCategory CreatePropertyFieldCategory(global::System.Int32 sequence)
 {
     PropertyFieldCategory propertyFieldCategory = new PropertyFieldCategory();
     propertyFieldCategory.Sequence = sequence;
     return propertyFieldCategory;
 }