Click here to Skip to main content
15,847,903 members

Comments by Majid Farhan (Top 8 by date)

Majid Farhan 28-Nov-22 7:39am View    
Sorry for that.
validation error: {"salesProductWeight":["The salesProductWeight field is required."]}

and this is the post code:


// POST: api/SalesItemLine
[HttpPost]
[Authorize]
public async Task<iactionresult> PostSalesItemLine([FromBody] SalesItemLine salesItemLine)
{
if (!ModelState.IsValid)
{
return BadRequest(ModelState);
}

SalesItem salesItem = await _context.SalesItem
.Where(x => x.Id.Equals(salesItemLine.SalesItemId)).FirstOrDefaultAsync();


salesItemLine.TotalAmount = (decimal)salesItemLine.Qty * salesItemLine.Price;

if (salesItemLine.SalesItemLineId == string.Empty)
{
var weight = _context.SalesProduct.Where(c => c.Id == salesItemLine.SalesItemId).Select(c => c.SalesProductWeight).FirstOrDefault();
var price = _context.SalesProduct.Where(c => c.Id == salesItemLine.SalesItemId).Select(c => c.SalesProductPrice).FirstOrDefault();
salesItemLine.SalesProductWeight = weight;
salesItemLine.Price = price;
salesItemLine.SalesItemLineId = Guid.NewGuid().ToString();
_context.SalesItemLine.Add(salesItemLine);
await _context.SaveChangesAsync();
return Json(new { success = true, message = "Add new data success." });
}
else
{
_context.Update(salesItemLine);
await _context.SaveChangesAsync();
return Json(new { success = true, message = "Edit data success." });
}

}
Majid Farhan 22-Jul-22 7:46am View    
Yes I did, and i posted here in code project, but because I am still learning, I can't handle errors well, that is why I trying to keep learning and practicing in parallel..
So we as ( a beginners) we need patience from experts people
Majid Farhan 22-Jul-22 6:55am View    
I seek solutions from all of you .. Instead of these instructions.. which I did it.
Of course I tried to solve it from a lot of sites, but couldn't successed ..
🙃
Majid Farhan 20-Jul-22 20:42pm View    
It's better to provide any help, because (NO RESPONDING THERE) was the reason I wrote here.

Thanks
Majid Farhan 12-Apr-22 14:34pm View    
Is my relationship code correct?