using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using CAPI.Custom.Data; using CAPI.Custom.Entities; namespace CAPI.Custom.Services.Quotes { public class FinalItemService : SurfaceChildItemService { private readonly string IN_STOCK = "STOCK"; public FinalItemService(QuotesContext db = null) { if (db.IsNotNull()) this.db = db; } public override IQueryable GetByParentId(int parentId) => base.GetByParentId(parentId) .OrderBy(p => p.Sequence); public IQueryable GetStockItems(int parentId) => GetByParentId(parentId) .Where(p => IN_STOCK.Equals(p.LeadTime, StringComparison.OrdinalIgnoreCase)); public int UpdateStatus(int itemId, bool status) { var entity = GetByItemId(itemId); int result = 0; if (entity.IsNotNull() && entity.Status != status) { entity.Status = status; result = Save(); } //if (result) //{ // QuoteItemsFinal_CalcualteTotals(userId, entity.ParentSurfaceItemId.Value); //} return result; } } }