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

Activities of "sampath"

Here I need to use same ui page for both creating and editing where I have tried as shown below. But it gives error when do the mapping here : var property = input.Property.MapTo<Property>(); inside the "CreatePropertyAsync()" method. Could you tell me where is the issue ? All primary keys are int type.Is that the problem on here : public int? Id { get; set; } in the " PropertyEditDto " object ? B'cos I have given it null-bale hence we don't have a "Id" key for the Create property scenario. Edit scenario we do have value for that.If it is the problem how can I do this ? Any help would be highly appreciated. Thanks in advance.

Mapping error is : Message "Missing type map configuration or unsupported mapping.\r\n\r\nMapping types:\r\nPropertyEditDto -> Property\r\.IP.IpProperties.Dtos.PropertyEditDto -> .IP.IpProperties.Property\r\n\r\nDestination path:\r\nProperty\r\n\r\nSource value:\r\.IP.IpProperties.Dtos.PropertyEditDto"	string

PropertyAppService.cs

public async Task CreateOrUpdatePropertyAsync(CreateOrEditPropertyInput input)
        {
            if (input.Property.Id.HasValue)
            {
                await UpdatePropertyAsync(input);
            }
            else
            {
                await CreatePropertyAsync(input);
            }
        }


public async Task CreatePropertyAsync(CreateOrEditPropertyInput input)
        {
            var property = input.Property.MapTo<Property>();
            await _propertyRepository.InsertAsync(property);
        }

Dtos

public class CreateOrEditPropertyInput : IInputDto
    {
        [Required]
        public PropertyEditDto Property { get; set; }
    }


   [AutoMapFrom(typeof(Property))]
    public class PropertyEditDto 
    {
        public const int MaxLength = 50;
        public int? Id { get; set; }

        [Required]
        [MaxLength(MaxLength)]
        public string Dist { get; set; }

        [Required]
        [MaxLength(MaxLength)]
        public string Sec { get; set; }

        [Required]
        public DateTime DeedDate { get; set; }

        [Required]
        public decimal TransferTax { get; set; }

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


        [Required]
        public AddressDto Address { get; set; }

    }  

    [AutoMapFrom(typeof(Address))]
    public class AddressDto : FullAuditedEntityDto, IOutputDto
    {
        public string StreetNumber { get; set; }
        public string StreetName { get; set; }
        public int CityId { get; set; }
        public CityListDto City { get; set; }
        public int StateId { get; set; }
        public StateListDto State { get; set; }
    }

[AutoMapFrom(typeof(City))]
    public class CityListDto : FullAuditedEntityDto
    {
        public string ZipCode { get; set; }
        public string Name { get; set; }
    }

     [AutoMapFrom(typeof(State))]
    public class StateListDto : FullAuditedEntityDto
    {
        public string Code { get; set; }
        public string Name { get; set; }
    }

Domain objects

[Table("IpProperties")]
    public class Property : FullAuditedEntity
    {
        public const int MaxLength = 50;

        
        [Required]
        [MaxLength(MaxLength)]
        public virtual string Dist { get; set; }

        [Required]
        [MaxLength(MaxLength)]
        public virtual string Sec { get; set; }


        [Required]
        public virtual DateTime DeedDate { get; set; }

        [Required]
        public virtual decimal TransferTax { get; set; }

        
        [ForeignKey("CountyId")]
        public virtual County County { get; set; }
        public virtual int CountyId { get; set; }


        public virtual Address Address { get; set; }


    [Table("IpCounties")]
    public class County : FullAuditedEntity
    {
        public const int MaxLength = 50;

        [Required]
        [MaxLength(MaxLength)]
        public virtual string Name { get; set; }

        [Required]
        [MaxLength(MaxLength)]
        public virtual string State { get; set; }

        public virtual ICollection<Property> Properties { get; set; }

    }


    [Table("IpCities")]
    public class City : FullAuditedEntity
    {
        public const int MaxLength = 50;

        [Required]
        [MaxLength(MaxLength)]
        public virtual string Name { get; set; }

        [Required]
        [MaxLength(MaxLength)]
        public virtual string ZipCode { get; set; }

        public virtual ICollection<Address> Addresses { get; set; }
    }


    [Table("IpStates")]
    public class State : FullAuditedEntity
    {
        public const int MaxLength = 50;

        [Required]
        [MaxLength(MaxLength)]
        public virtual string Code { get; set; }

        [Required]
        [MaxLength(MaxLength)]
        public virtual string Name { get; set; }
        public virtual ICollection<Address> Addresses { get; set; }
    }

Could you tell me how to set the 1 : 1 relationship with the below mentioned models when we use the Asp.net Boiler plait ? Thanks in advance.

Note : I have seen this nice answer about the EF 1 to 1 relationship.But unfortunately I don't know how to set it with the Boiler plate.B'cos PK is automatically taken from the ABP.On my scenario where both tables having int PK.

SO : [url]http://stackoverflow.com/questions/6531671/what-does-principal-end-of-an-association-means-in-11-relationship-in-entity-fr

Note 2 : Here Property and Address models having 1 : 1 Relationship.

Property Model

[Table("IpProperties")]
    public class Property : FullAuditedEntity
    {

        public virtual bool Vacant { get; set; }

        public virtual Address Address { get; set; }

}

Address Model

[Table("IpAddresses")]
    public class Address : FullAuditedEntity
    {

        [Required]
        [MaxLength(MaxLength)]
        public virtual string StreetNumber { get; set; }

        public virtual Property Property { get; set; }
    }
Showing 61 to 62 of 62 entries