public static List <GrantAllocationBudgetLineItem> CreateAllGrantAllocationBudgetLineItemsByCostType(this GrantAllocation grantAllocation) { var grantAllocationBudgetLineItems = new List <GrantAllocationBudgetLineItem>(); var shouldSaveChanges = false; foreach (var costType in CostType.GetLineItemCostTypes()) { var lineItemByCostType = grantAllocation.GrantAllocationBudgetLineItems.SingleOrDefault(bli => bli.CostTypeID == costType.CostTypeID); if (lineItemByCostType == null) { var tempLineItem = new GrantAllocationBudgetLineItem(grantAllocation.GrantAllocationID, costType.CostTypeID, 0); lineItemByCostType = HttpRequestStorage.DatabaseEntities.GrantAllocationBudgetLineItems.Add(tempLineItem); shouldSaveChanges = true; } grantAllocationBudgetLineItems.Add(lineItemByCostType); } if (shouldSaveChanges) { HttpRequestStorage.DatabaseEntities.SaveChanges(); } return(grantAllocationBudgetLineItems); }
public static void DeleteGrantAllocationBudgetLineItem(this IQueryable <GrantAllocationBudgetLineItem> grantAllocationBudgetLineItems, GrantAllocationBudgetLineItem grantAllocationBudgetLineItemToDelete) { DeleteGrantAllocationBudgetLineItem(grantAllocationBudgetLineItems, new List <GrantAllocationBudgetLineItem> { grantAllocationBudgetLineItemToDelete }); }
public static string GetDeleteGrantAllocationBudgetLineItemUrl(this GrantAllocationBudgetLineItem grantAllocationBudgetLineItem) { return(DeleteUrlTemplate.ParameterReplace(grantAllocationBudgetLineItem.GrantAllocationBudgetLineItemID)); }