th3criminal
New Member
So what I'm doing might seem simple, but I don't know exactly how to do it.I have already registered and logged in with an account (I'm using the default membership system used in ASP.NET MVC 4) and so I want to do add my UserId to some data I'm inserting to the database.This is the model of the data I'm inserting:\[code\]using System;using System.Collections.Generic;using System.Linq;using System.Web;namespace Reroute.Models{ public class Request { public int RequestId { get; set; } // I want to add UserId based on my current session public int UserId { get; set; } public string OrderNumber { get; set; } public string TrackingNumber { get; set; } public string CurrentAddress { get; set; } public string NewAddress { get; set; } public string Comment { get; set; } }}\[/code\]And the ActionResult (here's where I supposed I have to make the changes):\[code\][HttpPost] public ActionResult Create(Request collection) { try { _db.Requests.Add(collection); _db.SaveChanges(); //return RedirectToAction("Index"); return Content("Done! Added to DB"); } catch { return View(); } }\[/code\]Thanks