<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: alcam1965</title>
    <description>The latest articles on DEV Community by alcam1965 (@alcam1965).</description>
    <link>https://dev.to/alcam1965</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F905932%2Feab25e6d-f6c3-4709-a48a-44907e898955.png</url>
      <title>DEV Community: alcam1965</title>
      <link>https://dev.to/alcam1965</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/alcam1965"/>
    <language>en</language>
    <item>
      <title>Need help creating new child record with foreign key of paren</title>
      <dc:creator>alcam1965</dc:creator>
      <pubDate>Fri, 02 Sep 2022 09:32:48 +0000</pubDate>
      <link>https://dev.to/alcam1965/need-help-creating-new-child-record-with-foreign-key-of-paren-3pa1</link>
      <guid>https://dev.to/alcam1965/need-help-creating-new-child-record-with-foreign-key-of-paren-3pa1</guid>
      <description>&lt;p&gt;I'm building a CRUD Application to manage my company's back end and having issues with creating a new child record for a parent. The standard auto-generated controller based on the model is set up to create a new record but not a new child record so I need to modify the controller and or the models.  The models involved are: Bundle.cs and Agreement.cs:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;using System;
using System.Collections.Generic;

namespace AdminPortal.Models
{
    public partial class Bundle
    {
        public int Id { get; set; }
        public DateTime StartUtc { get; set; }
        public DateTime EndUtc { get; set; }
        public int Quantity { get; set; }
        public int? AgreementId { get; set; }
        public decimal? BundlePrice { get; set; }

        public virtual Agreement? Agreement { get; set; }
    }
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;using System;
using System.Collections.Generic;

namespace AdminPortal.Models
{
    public partial class Agreement
    {
        public Agreement()
        {
            AgreementAmendments = new HashSet&amp;lt;AgreementAmendment&amp;gt;();
            Bundles = new HashSet&amp;lt;Bundle&amp;gt;();
            Invoices = new HashSet&amp;lt;Invoice&amp;gt;();
        }

        public int Id { get; set; }
        public int OrgId { get; set; }
        public string? AgreementNumber { get; set; }
        public string? IrespondReference { get; set; }
        public string? DocumentLink { get; set; }

        public virtual Organization Org { get; set; } = null!;
        public virtual ICollection&amp;lt;AgreementAmendment&amp;gt; AgreementAmendments { get; set; }
        public virtual ICollection&amp;lt;Bundle&amp;gt; Bundles { get; set; }
        public virtual ICollection&amp;lt;Invoice&amp;gt; Invoices { get; set; }
    }
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is the create method in the Controller&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[HttpPost]
        [ValidateAntiForgeryToken]
        public async Task&amp;lt;IActionResult&amp;gt; Create([Bind("Id,StartUtc,EndUtc,Quantity,AgreementId,BundlePrice")] Bundle bundle)
        {
            if (ModelState.IsValid)
            {
                _context.Add(bundle);
                await _context.SaveChangesAsync();
                return RedirectToAction(nameof(Index));
            }
            return View(bundle);
        }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I'm new to EF Core so don't even know where to start.  &lt;/p&gt;

</description>
      <category>entityframework</category>
    </item>
    <item>
      <title>React Table not loading data</title>
      <dc:creator>alcam1965</dc:creator>
      <pubDate>Tue, 09 Aug 2022 14:00:45 +0000</pubDate>
      <link>https://dev.to/alcam1965/react-table-not-loading-data-1o53</link>
      <guid>https://dev.to/alcam1965/react-table-not-loading-data-1o53</guid>
      <description>&lt;p&gt;First post here so thanks in advance to any kind folk out there who can help me.  I'm working on a CRUD app using PERN stack and I'm having an issue with an edit form which is supposed to inherit the data from the row selected in an organization table. The component code is as follows:&lt;br&gt;
`import React, { useState, useContext, useEffect } from "react";&lt;br&gt;
import { useParams, useNavigate } from "react-router-dom";&lt;br&gt;
import { AppContext } from '../context/AppContext';&lt;br&gt;
import AdminPortal from '../apis/AdminPortal'&lt;/p&gt;

&lt;p&gt;const OrganizationUpdateForm = (props) =&amp;gt; {&lt;br&gt;
  const {id} = useParams()&lt;br&gt;
  const [name, setName] = useState("");&lt;br&gt;
  const [shortName, setShortName] = useState("");&lt;br&gt;
  const [parentOrg, setParentOrg] = useState("");&lt;br&gt;
  const [website, setWebsite] = useState("");&lt;br&gt;
  const [comments, setComments] = useState("");&lt;/p&gt;

&lt;p&gt;useEffect(() =&amp;gt; {&lt;br&gt;
    async function fetchData () {&lt;br&gt;
      const response = await AdminPortal.get(&lt;code&gt;organizations/${id}&lt;/code&gt;);&lt;br&gt;
      console.log(response.data.data);&lt;br&gt;
      setName(response.data.data.organizations.name);&lt;br&gt;
      setShortName(response.data.data.organizations.short_name);&lt;br&gt;
      setParentOrg(response.data.data.organizations.parent_org);&lt;br&gt;
      setWebsite(response.data.data.organizations.website);&lt;br&gt;
      setComments(response.data.data.organizations.comments);&lt;br&gt;
    };&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;fetchData();
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;}, []);&lt;/p&gt;

&lt;p&gt;let Navigate  = useNavigate(); &lt;br&gt;
  const handleSubmit = async (e) =&amp;gt; {&lt;br&gt;
    e.preventDefault();&lt;br&gt;
    const updateOrganization = await AdminPortal.put(&lt;code&gt;organizations/${id}&lt;/code&gt;, {&lt;br&gt;
      name,&lt;br&gt;
      short_name: shortName,&lt;br&gt;
      parent_org: parentOrg,&lt;br&gt;
      website,&lt;br&gt;
      comments&lt;br&gt;
    });&lt;br&gt;
    Navigate("/");&lt;br&gt;
  };&lt;/p&gt;

&lt;p&gt;return (&lt;br&gt;
    &lt;/p&gt;
&lt;br&gt;
      &lt;br&gt;
        &lt;br&gt;
          Name&lt;br&gt;
          
            value={name}&lt;br&gt;
            onChange={(e) =&amp;gt; setName(e.target.value)}&lt;br&gt;
            id="name"&lt;br&gt;
            className="form-control"&lt;br&gt;
            type="text"&lt;br&gt;
          /&amp;gt;&lt;br&gt;
        &lt;br&gt;
        &lt;br&gt;
          Short Name&lt;br&gt;
          
            value={shortName}&lt;br&gt;
            onChange={(e) =&amp;gt; setShortName(e.target.value)}&lt;br&gt;
            id="short_name"&lt;br&gt;
            className="form-control"&lt;br&gt;
            type="text"&lt;br&gt;
          /&amp;gt;&lt;br&gt;
        &lt;br&gt;
        &lt;br&gt;
          Parent Organization&lt;br&gt;
          
            value={parentOrg}&lt;br&gt;
            onChange={(e) =&amp;gt; setParentOrg(e.target.value)}&lt;br&gt;
            id="parent_org"&lt;br&gt;
            className="form-control"&lt;br&gt;
            type="text"&lt;br&gt;
          /&amp;gt;&lt;br&gt;
        &lt;br&gt;
        &lt;br&gt;
          Website&lt;br&gt;
          
            value={website}&lt;br&gt;
            onChange={(e) =&amp;gt; setWebsite(e.target.value)}&lt;br&gt;
            id="website"&lt;br&gt;
            className="form-control"&lt;br&gt;
            type="text"&lt;br&gt;
          /&amp;gt;&lt;br&gt;
        &lt;br&gt;
        &lt;br&gt;
          Comments&lt;br&gt;
          
            value={comments}&lt;br&gt;
            onChange={(e) =&amp;gt; setComments(e.target.value)}&lt;br&gt;
            id="name"&lt;br&gt;
            className="form-control"&lt;br&gt;
            type="text"&lt;br&gt;
          /&amp;gt;&lt;br&gt;
        &lt;br&gt;
        {/* 
          type="submit"&lt;br&gt;
          onClick={handleSubmit}&lt;br&gt;
          className="btn btn-primary"&lt;br&gt;
        &amp;gt;&lt;br&gt;
          Submit&lt;br&gt;
         */}&lt;br&gt;
      
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;/div&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;)&lt;br&gt;
}&lt;/p&gt;

&lt;p&gt;export default OrganizationUpdateForm&lt;/p&gt;

&lt;p&gt;`&lt;br&gt;
I get the correct response when I hit the API from Postman and the browser creates the correct URL but I am getting the following error: "A component is changing a controlled input to be uncontrolled. This is likely caused by the value changing from a defined to undefined, which should not happen. Decide between using a controlled or uncontrolled input element for the lifetime of the component."  After extensive Googling I haven't been able to find a solution so I'm hoping someone here can take a quick look and be able to figure out what I am doing wrong. Thanks in advance. &lt;/p&gt;

</description>
      <category>react</category>
      <category>tables</category>
    </item>
  </channel>
</rss>
