public int AddSales(AddSalesRequest addSales) { using (DataAccess dataAccess = new DataAccess()) { Sales sales = new Sales(); sales.SellerID = sellerService.GetSellerID(new Contracts.Request.Seller.GetSellerID(addSales.SellerName, addSales.SellerSurname, addSales.SellerEmail)); sales.CustomerID = addSales.CustomerID; sales.ProductID = addSales.ProductID; sales.SalesNumber = addSales.SalesNumber; sales.Cost = addSales.Cost; dataAccess.Sales.Add(sales); UpdateStockNumber(new UpdateStockNumberRequest(addSales.ProductID, addSales.SalesNumber)); dataAccess.SaveChanges(); var addedsales = dataAccess.Sales.Where(x => x.CustomerID == sales.CustomerID && x.SellerID == sales.SellerID && x.ProductID == sales.ProductID && x.SalesNumber == sales.SalesNumber && x.Cost == sales.Cost).OrderBy(x => x.SalesID); AddNotf(new AddNotificationRequest(addedsales.FirstOrDefault().SalesID)); return(dataAccess.SaveChanges()); } }