November Happy Hour will be moved to Thursday December 5th.

When i am getting records i got these errors by using RestApi and Code First Can you please some one help me

Vote:
 

Error CS0103 The name 'query' does not exist in the current context. 
Error CS0103 The name 'First' does not exist in the current context. 
Error CS0103 The name 'query.First' does not exist in the current context.
Error CS0161 'PurchaseOrderService.GetAllProductstatusdetails()': 
Error CS1519 Invalid token '(' in class, struct, or interface member declaration
Error CS1519 Invalid token '(' in class, struct, or interface member declaration
Error CS1519 Invalid token 'return' in class, struct, or interface member declaration
Error CS1513 } expected

This is my Purchaseorderservices.cs page.

using QFT_POMS_SVC.Domain.POMS;
using System.Collections.Generic;
using System.Linq;

namespace QFT_POMS_SVC.Services.POMS
{
public class PurchaseOrderService : IPurchaseOrderService
{
ProductStatusEntities entities = new ProductStatusEntities();
private DBMapper _dbContext;
private Result _result;
private object query;

public PurchaseOrderService()
{
_dbContext = new DBMapper();
_result = new Result();
}
public IList<Distributor> GetAllDistributorsOp()
{
var query = from d in _dbContext.DistributorRepository select d;
return query.ToList();
}
public IList<PurchaseOrder> GetAllPOByDistributorIdOp(int DistributorId)
{
var query = from po in _dbContext.PurchaseOrderRepository
where po.DistributorId == DistributorId
select po;

return query.ToList();
}

public PurchaseOrder GetPODetailsOp(int PurchaseOrderId)
{
var query = from po in _dbContext.PurchaseOrderRepository
where po.Id == PurchaseOrderId
select po;

return query.First();
}

private void UpdatePurchaseOrderItems(int purchaseorderid, List<PurchaseOrderItem> items)
{
foreach (var item in items)
{
var _item = _dbContext.PurchaseOrderItemsRepository.Where(po => po.Id == item.Id).First();
_item.QtyReceived = item.QtyReceived;
_item.Received = item.Received;
_item.UnitCostReceived = item.UnitCostReceived;
_item.Discontinued = item.Discontinued;
}
_dbContext.SaveChanges();
}

public Result UpdatePurchaseOrderOp(PurchaseOrder po)
{
var _purchaseOrder = GetPODetailsOp(po.Id);
_purchaseOrder.deleted = po.deleted;
_purchaseOrder.InvoiceDate = po.InvoiceDate;
_purchaseOrder.InvoiceDueDate = po.InvoiceDueDate;
_purchaseOrder.InvoiceNumber = po.InvoiceNumber;
//_purchaseOrder.items.Clear();

//_purchaseOrder.items = po.items;
_purchaseOrder.PORcvdAmount = po.PORcvdAmount;

UpdatePurchaseOrderItems(po.Id, po.items);


_dbContext.SaveChanges();
return _result;
}

public List<ProductStatusEntities> GetAllProductstatusdetails()
{
var query = from orditem in _dbContext.OrderItemRepository
from p in _dbContext.ProductRepository
from dpm in _dbContext.DistributorProductMappingRepository
from pwi in _dbContext.ProductWarehouseInventoryRepository
where
p.ProductTypeId == orditem.ProductId &&
dpm.ProductId == pwi.ProductId &&
dpm.ProductId == orditem.ProductId &&
orditem.Order.OrderStatusId == 20
group new { orditem, p, dpm.Distributor, dpm, pwi } by new
{
orditem.ProductId,
orditem.OrderId,
p.Name,
p.ProductTypeId,
Column1 = dpm.Distributor.Name,
dpm.StockStatus,
dpm.UnitPrice,
pwi.StockQuantity,
Column2 = p.StockQuantity
} into g
select new
{
g.Key.OrderId,
g.Key.ProductId,
productname = g.Key.Name,
g.Key.UnitPrice,
Distributorname = g.Key.Column1,
orderquantity = (int?)g.Sum(p => p.orditem.Quantity),
TotalQuantity = (int?)g.Sum(p => p.pwi.StockQuantity + p.dpm.StockStatus + p.p.StockQuantity); }

return query.First();
}

}

#204876
Edited, Jun 20, 2019 10:24
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.