Starts in:
1 DAY
23 HRS
14 MIN
47 SEC
Starts in:
1 D
23 H
14 M
47 S

Activities of "Karunakar"

Hi Liangshiwei, I have tried with above code but the entire record is deleted instead softdelete(IsDelete=0).

private readonly IVendorRepository _VendorRepository; public async Task DeleteAsync(Guid id) { await _VendorRepository.DeleteAsync(x=>x.VendorId == id); }

public interface IVendorRepository : IRepository<Vendor, Guid>, ITransientDependency { }

I will try by applying the above changes but what about DeletorId to update in DB for delete.

public enum TypeOfVendors
{
    Standard,
    CreditCard,
    Pcard,
    Pc,
    TaxAgency,
    PayrollCompany,
    ShippingPartner,
    Pdecm,
    Director,
    SalesRep,
    Messenger,
    CarService,
    Phones,
    Bidder,
    ExecutiveProducer,
    DirectorOfPhotography,
    Producer

}

this is my Entity

[Table("Vendor")]
public class Vendor : AggregateRoot<Guid>, IHasCreationTime, IMustHaveCreator, IMultiTenant, ISoftDelete, IHasDeletionTime
{
    public Vendor()
    {
        Active = true;
        Is1099 = false;
        IsW9OnFile = false;
        IsDeleted = false;
    }
  
    [Key]
    public Guid VendorId { get; set; }
    [Required]
    [StringLength(VendorConsts.FirstNameLength, MinimumLength = VendorConsts.MinLength)]
    public string FirstName { get; set; }

    [Required]
    [StringLength(VendorConsts.LastNameLength, MinimumLength = VendorConsts.MinLength)]
    public string LastName { get; set; }

    [StringLength(VendorConsts.VendorNameLength, MinimumLength = VendorConsts.MinLength)]
    public virtual string? VendorName { get; set; }

   // public virtual int? TypeOfVendorId { get; set; }

    //Navigation Property to the VendorId entity
    [ForeignKey("TypeOfVendorId")]
    public virtual TypeOfVendors TypeOfVendorId { get; set; }  // Navigation property

    [StringLength(VendorConsts.DbaFsoNameLength, MinimumLength = VendorConsts.MinLength)]
    public virtual string? DbaFsoName { get; set; }

    [StringLength(VendorConsts.PayToNameLength, MinimumLength = VendorConsts.MinLength)]
    public virtual string? PayToName { get; set; }

    [StringLength(VendorConsts.VendorNumberLength, MinimumLength = VendorConsts.MinLength)]
    public virtual string? VendorNumber { get; set; }

    [StringLength(VendorConsts.SSN_FederalTaxIdLength, MinimumLength = VendorConsts.MinLength)]
    public virtual string? SSN_FederalTaxId { get; set; }

    [Required]
    public int TaxType { get; set; }

    [StringLength(VendorConsts.BillingAccountNumberLength, MinimumLength = VendorConsts.MinLength)]
    public virtual string? BillingAccountNumber { get; set; }

    public virtual Guid? PaymentTerm { get; set; }

    [Required]
    public bool Is1099 { get; set; }

    [Required]
    public bool IsW9OnFile { get; set; }

    public virtual int? TypeOf1099 { get; set; }

    public virtual Guid? ACHInfoId { get; set; }

    // Navigation Property to the VendorId entity
    [ForeignKey("ACHInfoId")]
    public virtual ACHInfo AchInformation { get; set; }  // Navigation property

    public bool Active { get; set; }

    public virtual Guid? DefaultJobIdProjectDivision { get; set; }

    public virtual Guid? DefaultGlAccount { get; set; }

    public virtual Guid? DefaultLineNumber { get; set; }

    public virtual Guid? DefaultSeries { get; set; }

    public virtual Guid? DefaultLocation { get; set; }

    public virtual Guid? DefaultSet { get; set; }

    public virtual Guid? DefaultInsRef { get; set; }

    public virtual Guid? DefaultFF1 { get; set; }

    public virtual Guid? DefaultFF2 { get; set; }

    public virtual Guid? DefaultFF3 { get; set; }

    public virtual Guid? DefaultFF4 { get; set; }

    public virtual Guid? Notes { get; set; }

    public virtual int? Currency { get; set; }

    public virtual Guid? AdvanceAccount { get; set; }

    public virtual Guid? PcardAdvanceAccount { get; set; }

    [StringLength(VendorConsts.StudioVendorNumberLength, MinimumLength = VendorConsts.MinLength)]
    public virtual string? StudioVendorNumber { get; set; }

    [StringLength(VendorConsts.CustomerNumberLength, MinimumLength = VendorConsts.MinLength)]
    public virtual string? CustomerNumber { get; set; }

    public virtual int? BusinessCategory { get; set; }

    [Required]
    public int Ethnicity { get; set; }
  
    [Required]
    public virtual bool IsThirdPartyVendor { get; set; }

    public virtual Guid? TenantId { get; set; }

    public virtual Guid CreatorId { get; set; }

    [Column(TypeName = "datetime")]
    public virtual DateTime CreationTime { get; set; }

    public bool IsDeleted { get; set; }

    public virtual Guid? DeletedByUser { get; set; }

    [Column(TypeName = "datetime")]
    public virtual DateTime? DeletionTime { get; set; }

    public Vendor(
        Guid vendorId, string firstName, string lastName, string? vendorName, TypeOfVendors typeOfVendorId,
        string? dbaFsoName, string? payToName, string? vendorNumber, string? sSN_FederalTaxId,
        int taxType, string? billingAccountNumber, Guid? paymentTerm,
        bool is1099, bool isW9OnFile, int? typeOf1099, Guid? aCHInfoId,
        bool active, Guid? defaultJobIdProjectDivision, Guid? defaultGlAccount,
        Guid? defaultLineNumber, Guid? defaultSeries, Guid? defaultLocation,
        Guid? defaultSet, Guid? defaultInsRef, Guid? defaultFF1, Guid? defaultFF2,
        Guid? defaultFF3, Guid? defaultFF4, Guid? notes, int? currency,
        Guid? advanceAccount, Guid? pcardAdvanceAccount, string? studioVendorNumber,
        string? customerNumber, int? businessCategory, int ethnicity,
        bool isThirdPartyVendor, Guid? tenantId, Guid creatorId,
        DateTime createDateTime, bool isDeleted, Guid? deletedByUser, DateTime? deletionTime)
    {
        VendorId = vendorId;
        FirstName = firstName;
        LastName = lastName;
        VendorName = vendorName;
        TypeOfVendorId = typeOfVendorId;
        DbaFsoName = dbaFsoName;
        PayToName = payToName;
        VendorNumber = vendorNumber;
        SSN_FederalTaxId = sSN_FederalTaxId;
        TaxType = taxType;
        BillingAccountNumber = billingAccountNumber;
        PaymentTerm = paymentTerm;
        Is1099 = is1099;
        IsW9OnFile = isW9OnFile;
        TypeOf1099 = typeOf1099;
        ACHInfoId = aCHInfoId;
        Active = active;
        DefaultJobIdProjectDivision = defaultJobIdProjectDivision;
        DefaultGlAccount = defaultGlAccount;
        DefaultLineNumber = defaultLineNumber;
        DefaultSeries = defaultSeries;
        DefaultLocation = defaultLocation;
        DefaultSet = defaultSet;
        DefaultInsRef = defaultInsRef;
        DefaultFF1 = defaultFF1;
        DefaultFF2 = defaultFF2;
        DefaultFF3 = defaultFF3;
        DefaultFF4 = defaultFF4;
        Notes = notes;
        Currency = currency;
        AdvanceAccount = advanceAccount;
        PcardAdvanceAccount = pcardAdvanceAccount;
        StudioVendorNumber = studioVendorNumber;
        CustomerNumber = customerNumber;
        BusinessCategory= businessCategory;
        Ethnicity = ethnicity;
        IsThirdPartyVendor = isThirdPartyVendor;
        TenantId = tenantId;
        CreatorId = creatorId;
        CreationTime = createDateTime;
        IsDeleted = isDeleted;
        DeletedByUser = deletedByUser;
        DeletionTime = deletionTime;
    }
}
private static void ConfigureVendor(ModelBuilder builder)
 {
     builder.Entity<Vendor>(b =>
     {
         // Get the entity type
         var entityType = typeof(Vendor);
         // Retrieve the Table attribute from the entity type
         var tableAttribute = entityType.GetCustomAttributes(typeof(TableAttribute), false)
                                        .Cast<TableAttribute>()
                                        .FirstOrDefault();

         // Extract the table name
         var tableName = tableAttribute?.Name ?? entityType.Name;

         //Configure table & schema name
         b.ToTable(tableName, VendorManagementDbProperties.DbSchema);

         b.ConfigureByConvention();
         b.Ignore(q => q.ExtraProperties);
         b.Ignore(q => q.Id);

         // Primary Key Configuration
         b.HasKey(v => v.VendorId);

         // Properties Configuration
         b.Property(v => v.FirstName)
             .HasMaxLength(VendorConsts.FirstNameLength)
             .IsRequired();

         b.Property(v => v.LastName)
             .HasMaxLength(VendorConsts.LastNameLength)
             .IsRequired();   
          
         b.Property(v => v.BillingAccountNumber)
             .HasMaxLength(VendorConsts.BillingAccountNumberLength);

         b.Property(v => v.Is1099)
             .IsRequired().HasDefaultValue(false);

         b.Property(v => v.IsW9OnFile)
             .IsRequired().HasDefaultValue(false);

         b.Property(v => v.Active)
             .IsRequired().HasDefaultValue(true);

         b.Property(q => q.CreatorId)
             .IsRequired();

         b.Property(q => q.CreationTime).HasDefaultValueSql("CURRENT_TIMESTAMP")
             .IsRequired();

         b.Property(q => q.IsDeleted)
             .HasDefaultValue(false);

         b.HasOne(v => v.AchInformation)
             .WithMany()  // Assuming a one-to-many relationship with AchInformation
             .HasForeignKey(v => v.ACHInfoId)
             .OnDelete(DeleteBehavior.SetNull);

         // Store the enum value as an integer in the database
         b.Property(v => v.TypeOfVendorId)
             .HasConversion<int>(); // This ensures EF Core treats the enum as an integer value in the database

     });
 }

Now, evertything working fine many thanks!.

or else could you please share my project by correct it how exactly we need to write?

If you seen I followed the same but still getting my repository getting null in reository_tests after test data seeded. If you had some free time we can connect for a while

please suggest the correct process

If not added then getting autofac exception

Showing 1 to 10 of 13 entries
Made with ❤️ on ABP v9.1.0-preview. Updated on November 20, 2024, 13:06