/// <summary> /// Alter quantity of a given location's associated product by given amount. /// </summary> /// <param name="location"></param> /// <param name="product"></param> /// <param name="amount"></param> public void AddProductToLocation(Location location, Product product, int amount) { LocationLine locationLine = locationLines.Where(x => x.LocationId == location.Id && x.ProductId == product.Id).FirstOrDefault(); locationLine.Quantity += amount; _dbContext.SaveChanges(); }
/// <summary>Decreases item stock</summary><param name="store">The Location at where shopping is occuring</param><param name="item">The Product that is being purchased</param><param name="quantity">The quantity that is being purchased</param> private void Purchase(Location store, Product item, int quantity) { LocationLine l = store.Items.Where(x => x.Item.Id == item.Id).FirstOrDefault(); if (l == null) { throw new Exception("ERROR!!!! SHOULD NOT HAPPEN!"); } l.Stock -= quantity; _context.SaveChanges(); }
public RevitFaceWall(string family, string type, Surface face, Level level, LocationLine locationLine = LocationLine.Interior, [SchemaParamInfo("Set in here any nested elements that this level might have.")] List <Base> elements = null, List <Parameter> parameters = null) { this.family = family; this.type = type; this.face = face; this.locationLine = locationLine; this.level = level; this.elements = elements; this.parameters = parameters; }
private static Customer customer_A; // = new Customer("Fernando", "Alonso", "Spain", "1111111111"); private static void DefaultAddItemsToContext(P1_DbContext context) { product_A = new Product("Wrench", 20, "Red"); product_B = new Product("Hammer", 15, "Black"); location_A = new Location("Queens"); locationLine_A = new LocationLine(100, product_A.Id, location_A.Id); locationLine_B = new LocationLine(50, product_B.Id, location_A.Id); customer_A = new Customer("Fernando", "Alonso", "Spain", "1111111111"); customer_A = new Customer("Fernando", "Alonso", "Spain", "1111111111"); context.Products.Add(product_A); context.Products.Add(product_B); context.Locations.Add(location_A); context.LocationLines.Add(locationLine_A); context.LocationLines.Add(locationLine_B); context.Customers.Add(customer_A); }
/// <summary> /// BindDataToSelectLine control /// </summary> /// <param name="dataTable">selected data</param> private void BindDataToClbSelectLine(DataTable dataTable) { if (clbSelectLine.Items.Count > 0) { clbSelectLine.Items.Clear(); } List <LocationLine> roleList = new List <LocationLine>(); for (int i = 0; i < dataTable.Rows.Count; i++) { LocationLine lEntity = new LocationLine(); lEntity.LineKey = dataTable.Rows[i][FMM_LOCATION_LINE_FIELDS.FIELD_LINE_KEY].ToString(); lEntity.LineName = dataTable.Rows[i][FMM_PRODUCTION_LINE_FIELDS.FIELD_LINE_NAME].ToString(); roleList.Add(lEntity); } clbSelectLine.Items.AddRange(roleList.ToArray()); }
/// <summary> /// Returns the product of a specified location line. /// </summary> /// <param name="locationLine"></param> /// <returns>Product</returns> public Product GetSpecificProduct(LocationLine locationLine) { return(products.Where(x => x.Id == locationLine.ProductId).FirstOrDefault()); }
/// <summary> /// Returns the quantity of a product on a specified location line. /// </summary> /// <param name="p"></param> /// <param name="l"></param> /// <returns>int</returns> public int QuantityOfProduct(Product p, LocationLine l) { return(locationLines.Where(x => x.ProductId == p.Id && x.Id == l.Id).FirstOrDefault().Quantity); }