X Tutup
The Wayback Machine - https://web.archive.org/web/20201221091734/https://github.com/microsoft/InventorySample/issues/65
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error in DataServiceBase.OrderItems class #65

Open
fmassicci opened this issue Jul 31, 2020 · 1 comment
Open

Error in DataServiceBase.OrderItems class #65

fmassicci opened this issue Jul 31, 2020 · 1 comment

Comments

@fmassicci
Copy link

@fmassicci fmassicci commented Jul 31, 2020

public async Task UpdateOrderItemAsync(OrderItem orderItem)
{
if (orderItem.OrderLine > 0)
{
_dataSource.Entry(orderItem).State = EntityState.Modified;
}
else
{
orderItem.OrderLine = _dataSource.OrderItems.Where(r => r.OrderID == orderItem.OrderID).Select(r => r.OrderLine).DefaultIfEmpty(0).Max() + 1;
// TODO:
//orderItem.CreateOn = DateTime.UtcNow;
_dataSource.Entry(orderItem).State = EntityState.Added;
}
// TODO:
//orderItem.LastModifiedOn = DateTime.UtcNow;
//orderItem.SearchTerms = orderItem.BuildSearchTerms();
return await _dataSource.SaveChangesAsync();
}

orderItem.OrderLine = .... not working

@fmassicci
Copy link
Author

@fmassicci fmassicci commented Aug 28, 2020

In reference to my post I would like to suggest a solution:
IList items = _dataSource.OrderItems.Where(r => r.OrderID == objItem.OrderID).ToList();
objItem.OrderLine = items.Select(r => r.OrderLine).DefaultIfEmpty(0).Max() + 1;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
1 participant
You can’t perform that action at this time.
X Tutup