I'm building a CRUD that is accessible only to logged in users and i'm trying to add extra information (userid) to the crud records. How do I go about fetching the userId and saving it with the record?
Here is my controller
public ActionResult Create()
{
    return View();
}
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult Create([Bind(Include = "CompanyName,Telephone")]Company company)
{
    try
    {
        if (ModelState.IsValid)
        {
            db.Companies.Add(company);
            db.SaveChanges();
            return RedirectToAction("Index");
        }
    }
    catch (DataException /* dex */)
    {
        ModelState.AddModelError("", "Unable to save changes.");
    }
    return View(company);
}
Here is my model
namespace ProjectX.Models
{
    public class Company
    {
        //public int Id { get; set; }
        public int CompanyID { get; set; }
        public string CompanyName { get; set; }
        public string Telephone { get; set; }
    }
}
Thank you for your help!
 
     
    