using Microsoft.Azure.CosmosDB.Table; using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations.Schema; using System.Linq; using System.Text; using System.Threading.Tasks; using webapi.Domain.AggregatesModel.FlatAggregate; using webapi.Domain.Events; using webapi.Domain.SeedWork; namespace webapi.Domain.AggregatesModel.UserFlatMappingAggregate { [Table("mdbUsersFlatsMappings")] public class UserFlatMapping : Entity, IAggregateRoot { public UserFlatMapping() { } public UserFlatMapping(Guid flatId, Guid userId, string pmsUserName, Guid id) { Id = id; FlatId = flatId; UserId = userId; IsAutomatic = false; PMSUserName = pmsUserName; RequestApprovalModelDate = new RequestApprovedDate(); PartitionKey = FlatId.ToString(); RowKey = Id.ToString(); } /// /// Id for identifying each mapping /// //private Guid _id; //public Guid Id => _id; /// /// User id from mdb_UsersAuth AzureDB table /// public Guid UserId { get; set; } /// /// Flat if from mdb_Flats AzureDB table /// //private Guid _flatId; public Guid FlatId { get; set; } /// /// Datetime when request was approved /// public RequestApprovedDate RequestApprovalModelDate { get; private set; } /// /// Datetime when request was approved /// public DateTime RequestApprovalDate { get { return RequestApprovalModelDate.Date; } set { RequestApprovalModelDate = new RequestApprovedDate(value); } } /// /// UserId from Taloyhtio FBA database of the PM which approved request.Filled only when mapping is created from manual approval workflow.When mapping is created automatically it is left empty /// public Guid ApprovedBy { get; set; } /// /// Id of parent approval request from mdb_UsersFlatsApprovalRequests table to know form whch request this mapping was created.Filled only when mapping is created from manual approval workflow.When mapping is created automatically it is left empty /// public Guid ApprovalRequestId { get; set; } /// /// Flag which indicates whether this mapping was created automatically based on user PIN (see 4.1. Add and manage flats in database) or from manual approval workflow /// public bool IsAutomatic { get; set; } /// /// A user name which can be imported from PMS /// public string PMSUserName { get; set; } public void SetAutomatic() { this.IsAutomatic = true; } public void DeleteApprovals(Guid userId) { AddDomainEvent(new DeleteUserToFlatMappingApprovalDomainEvent(this.FlatId, userId)); } //public void RevokeUserAssignment(string userName, Guid condoId, Flat flat) //{ // AddDomainEvent(new RevokeUserAssignmentDomainEvent(userName, condoId, flat)); //} } }