hi
json result is wrapped inside "result" object .how I can change or rename that ex: original :- "result" : { name:"mike", } desired: "data":{[ name:"mike", ]} thanks
public async Task CreateSale(CreateSaleInput input) {
var person = input.MapTo<Salemast>();
await _saleRepository.InsertAsync(person);
}
please tell me what exactly you want me to share. i will try to post
i can even see the insert statement in sqlprofiler but it is not written in database ,I wonder if it is rollbacked or how ?
The thread 0x291c has exited with code 259 (0x103). Opened connection asynchronously at 3/7/2016 8:57:21 PM +08:00
INSERT [dbo].[Sale_Mast]([TenantId], [Invdt], [Invduedt], [Currency], [Currate], [Custid], [Export], [Comments], [Invno], [Branchid], [IsDeleted], [DeleterUserId], [DeletionTime], [LastModificationTime], [LastModifierUserId], [CreationTime], [CreatorUserId], [Id]) VALUES (@0, @1, @2, @3, @4, @5, @6, @7, @8, NULL, @9, NULL, NULL, NULL, NULL, @10, @11, @12) SELECT [Sslno] FROM [dbo].[Sale_Mast] WHERE @@ROWCOUNT > 0 AND [Sslno] = scope_identity()
-- @0: '2' (Type = Int32)
-- @1: '3/7/2016 12:00:00 AM' (Type = DateTime2)
-- @2: '3/7/2016 12:00:00 AM' (Type = DateTime2)
-- @3: 'USD' (Type = String, Size = -1)
-- @4: '1' (Type = Decimal, Precision = 18, Scale = 2)
-- @5: 'harry' (Type = String, Size = -1)
-- @6: 'False' (Type = Boolean)
-- @7: 'lol' (Type = String, Size = -1)
-- @8: '100' (Type = String, Size = 50)
-- @9: 'False' (Type = Boolean)
-- @10: '3/7/2016 8:57:21 PM' (Type = DateTime2)
-- @11: '3' (Type = Int64)
-- @12: '0' (Type = Int32)
-- Executing asynchronously at 3/7/2016 8:57:21 PM +08:00
-- Completed in 3 ms with result: SqlDataReader
Closed connection at 3/7/2016 8:57:21 PM +08:00
The thread 0x4938 has exited with code 259 (0x103).
by changing it to Entitydto , am i loosing anything :?: ?
yes , I have corrected it thanks :D
while creating new record error is coming .Reading record is working fine.mentioned below Error,Model entity ,Input entity
error : A first chance exception of type 'AutoMapper.AutoMapperMappingException' occurred in AutoMapper.dll
salemast class
public virtual int TenantId { get; set; }
[Table("Sale_Mast")]
public class Salemast : FullAuditedEntity, IMustHaveTenant
{
public virtual int TenantId { get; set; }
[Required]
[DataType(DataType.Date)]
[DisplayFormat(DataFormatString = "{0:yyyy-MM-dd}", ApplyFormatInEditMode = true)]
public virtual System.DateTime Invdt { get; set; }
[Required]
[DataType(DataType.Date)]
[DisplayFormat(DataFormatString = "{0:yyyy-MM-dd}", ApplyFormatInEditMode = true)]
public virtual System.DateTime Invduedt { get; set; }
[Required]
public virtual string Currency { get; set; }
[Required]
public virtual decimal Currate { get; set; }
[Required]
public virtual string Custid { get; set; }
[Required]
public virtual bool Export { get; set; }
[Required]
public virtual string Comments { get; set; }
[Required]
[StringLength(50)]
public virtual string Invno { get; set; }
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public virtual int Sslno { get; set; }
public virtual string Branchid { get; set; }
public virtual ICollection<Saledetails> Saledetails { get; set; }
}
[AutoMapFrom(typeof(Salemast))] public class CreateSaleInput : IInputDto {
[Required]
public System.DateTime Invdt { get; set; }
[Required]
public System.DateTime Invduedt { get; set; }
[Required]
public string Currency { get; set; }
[Required]
public decimal Currate { get; set; }
[Required]
public string Custid { get; set; }
public bool Export { get; set; }
public string Comments { get; set; }
[Required]
[StringLength(50)]
public string Invno { get; set; }
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int Sslno { get; set; }
public string Branchid { get; set; }
}
Hi thanks I changed it to Entitydto and those fields are gone but still there is one extra field 'id' .And tenant id keep displaying zero
my salesdto and json response is mentioned below .though i have not defined those properties in dto but it is automatically added to the return value.
[AutoMapFrom(typeof(Salemast))] public class Salelistdto : FullAuditedEntityDto { [Required] public int TenantId { get; set; } [Required] public System.DateTime Invdt { get; set; } [Required] public System.DateTime Invduedt { get; set; } [Required] public string Currency { get; set; } [Required] public decimal Currate { get; set; } [Required] public string Custid { get; set; } public bool Export { get; set; } public string Comments { get; set; }
[Required]
public string Invno { get; set; }
public int Sslno { get; set; }
public string Branchid { get; set; }
public decimal Amount { get; set; }
int termvalue;
public int Terms
{
get
{
return Convert.ToInt32(Invduedt.Subtract(Invdt).TotalDays);
}
set
{
termvalue = value;
}
}
public Collection<Saledetailslistdto> Saledetails { get; set; }
}
json response from getsale
{ "success": true, "result": { "filter": null, "items": [ { "tenantId": 0, "invdt": "2015-02-02T00:00:00", "invduedt": "2015-03-03T00:00:00", "currency": "USD", "currate": 6.00, "custid": "MrX", "export": false, "comments": "okok", "invno": "10", "sslno": 0, "branchid": null, "amount": 2000.0000, "terms": 29, "saledetails": null, <span style="color:#FF0040">"isDeleted": false, "deleterUserId": null, "deletionTime": null, "lastModificationTime": null, "lastModifierUserId": null, "creationTime": "2016-03-03T23:33:26.2537063+08:00", "creatorUserId": null, "id": 0</span> },
I have followup questions
1 should i make separate repository and dtos for the all entities including the child entity?
2.I dont want to send extra info(tenantid , creationdate etc ) to the the client side, but they are automatically added by the platform.
3.why my tenantid is showing zero