Base solution for your next web application
Starts in:
01 DAYS
01 HRS
01 MIN
01 SEC

Activities of "OutdoorEd"

There are dozens of child tables so I've simplified the model to show a short version the main parent table INCIDENT and just one child table - COMMUNICATIONLOG. TenantId is saved in the Incidents Table and also is saved in all the child tables. Having TenantId in all child tables provides row level security.

INCIDENTS namespace OE_Tenant.Web.Areas.Incidents.Models { using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; using System.Data.Entity.Spatial;

[Table("idb_Incident")]
public partial class Incident
{
    [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")]
    public Incident()
    {
        CommunicationLog = new HashSet<CommunicationLog>();
    }

    [Key]
    public Guid IncidentId { get; set; }

    [UIHint("GridForeignKey")]
    public int IncidentCategoryId { get; set; }

    [Required]
    [Column(TypeName = "smalldatetime")]
    public DateTime? IncidentDate { get; set; }

    [Required]
    [StringLength(200)]
    public string IncidentEvent { get; set; }

    [UIHint("GridForeignKey")]
    public int IncidentTypeId { get; set; }

    [Column(TypeName = "datetime2")]
    public DateTime DateEntered { get; set; }

	[Column(TypeName = "datetime2")]
    public DateTime? DateUpdated { get; set; }

    public int TenantId { get; set; }

    public virtual LkpIncidentCategory LkpIncidentCategory { get; set; }

    public virtual LkpIncidentType LkpIncidentType { get; set; }

    [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
    public virtual ICollection<CommunicationLog> CommunicationLog { get; set; }

}

}

COMMUNICATIONLOG

using System.ComponentModel;

namespace OE_Tenant.Web.Areas.Incidents.Models

{ using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; using System.Data.Entity.Spatial;

[Table("idb_CommunicationLog")]
public partial class CommunicationLog
{

    [Key]
    public Guid CommunicationLogId { get; set; }

    [DisplayName("Communication Type")]
    [UIHint("GridForeignKey")]
    public int CommunicationTypeId { get; set; }

    [DisplayName("Direction")]
    [UIHint("GridForeignKey")]
    public int CommunicationDirectionId { get; set; }

    public Guid IncidentId { get; set; }

    [DataType(DataType.Date)]
    [DisplayFormat(ApplyFormatInEditMode = true, DataFormatString = "{0:MM/dd/yyyy}")]
    public DateTime? Date { get; set; }

    [DataType(DataType.Time)]
    [DisplayFormat(ApplyFormatInEditMode = true, DataFormatString = "{0:t}")]
    public TimeSpan? StartTime { get; set; }

    [DataType(DataType.Time)]
    [DisplayFormat(ApplyFormatInEditMode = true, DataFormatString = "{0:t}")]
    public TimeSpan? EndTime { get; set; }

    [StringLength(50)]
    public string FirstName { get; set; }

    [StringLength(50)]
    [Display(Name = "Last Name", Prompt = "Enter person's last name")]
    public string LastName { get; set; }

    [StringLength(200)]
    public string Address1 { get; set; }

    [StringLength(100)]
    public string CountryCode { get; set; }

    [Column(TypeName = "datetime2")]
    public DateTime DateEntered { get; set; }

    [Column(TypeName = "datetime2")]
    public DateTime DateUpdated { get; set; }

    public int TenantId { get; set; }

    public virtual LkpCommunicationDirection LkpCommunicationDirection { get; set; }

    public virtual LkpCommunicationType LkpCommunicationType { get; set; }

    public virtual Incident Incident { get; set; }

    public virtual LkpCountry LkpCountry { get; set; }
}

}

I am using ASP.NET Zero as the authentication platform for a multi-tenant application. Once logged in individual tenants submit accident data to a separate database. I need to do two things with TenantId.

  1. Filter accident data by TenantId so that each Tenant can only view their own data. I have a TenantId as a field in the Accident table. I think this can be done in my AccidentModel using some code for EntityFramework.Dynamic Filters but do not know how to implement the code.

  2. I need to be able to access the TenantID as a Claim or Session variable for CRUD operations and don't know what code I would need to do that.

Thank you

I will be using the multitenant option and want to sell my SaaS product at different levels based on the number of User Licenses for each Tenant - example 5 Users, 10 Users, etc. A Tenant could have as many User Accounts as they want but only the Number of User Licenses purchased could be active at any one time. So the Tenant could purchase a 10 User License and could create 10 Active Users. In order to add another Active User, they would have to Deactivate one user. So they could have 11 users (or more) but only 10 Active Users. This would be a great addition to my project.

Is this a feature that you would consider adding?

Showing 71 to 73 of 73 entries