It will sound like a stupid question, but I'm just wondering if I have any trick left.
Scenario: I have a web application using Simple Memebership where users can register to use it (for example, an invoice program).
However, they should be able to view / update / delete information that they themselves add to the database / web application.
What is the best way to ensure that the user gets access to their information?
Whether to add a custom field to each table, for example:
public class Invoice
{
public int InvoiceId { get; set; }
public int CustId { get; set; }
public string UserName { get; set; }
}
public class Item
{
public int ItemId { get; set; }
public int InvoiceId { get; set; }
public string UserName { get; set; }
}
... and then in any controller that accesses the data, just add a check for the username in each request, for example:
var Inv = db.Invoices.Where(x => x.UserName = User.Identity.Name);
var Itm = db.Items.Where(y => y.UserName = User.Identity.Name);
, , , ? , , MVC4?
_ UserId UserProfile, ?
,
, 10 , -. , - - .
.