public async Task DeleteShelf(string symbol) { var shelfToDelete = Shelves.FirstOrDefault(x => x.Symbol == symbol); shelfToDelete.QuantityInStock = 0; await UpdateShelf(shelfToDelete); }
public void Pack(Bin bin) { Shelf shelf = null; int y = 0; foreach (var s in Shelves) { if (s.RemainingWidth >= bin.Size.x && s.Height >= bin.Size.y) { shelf = s; break; } y += s.Height + BinPadding.y; } if (shelf == null) { // Didn't fit on any shelves; add a new one shelf = new Shelf(); shelf.RemainingWidth = Width; shelf.Height = bin.Size.y; shelf.YOffset = y; Shelves.Insert(0, shelf); Height += bin.Size.y; } bin.Position = new Vec2i(Width - shelf.RemainingWidth, shelf.YOffset); shelf.Bins.Add(bin); shelf.RemainingWidth -= bin.Size.x + BinPadding.x; }
public OrdersDataGenerator() { Regions = GetRegionFaker(GetRegions()).Generate(5); Temperatures = GetTemperatureFaker(GetTemperatures()).Generate(4); Addresses = GetAddressFaker(GetCities(), GetStreets(), GetZipCodes(), Regions.Select(x => x.RegionId)).Generate(20); Restaurants = GetRestaurantFaker(GetRestaurants(), Addresses.Select(x => x.AddressId)).Generate(10); Menus = GetMenuFaker(GetMenus(), Restaurants.Select(x => x.RestaurantId)).Generate(3); MenuItems = GetMenuItemFaker(GetMenuItems(), Temperatures.Select(x => x.TemperatureId), Menus.Select(x => x.MenuId)).Generate(20); Customers = GetCustomerFaker(GetFirstNames(), GetLastNames(), Addresses.Select(x => x.AddressId)).Generate(5); Ingredients = GetIngredientFaker(GetIngredients(), Temperatures.Select(x => x.TemperatureId)).Generate(15); InventoryItems = GetInventoryItemFaker(Ingredients.Select(x => x.IngredientId), Restaurants.Select(x => x.RestaurantId)).Generate(20); MenuItemIngredients = GetMenuItemIngredientFaker(MenuItems.Select(x => x.MenuItemId), Ingredients.Select(x => x.IngredientId)).Generate(50); var shelves = new List <ShelfEntity>(); for (int i = 0; i < 3; i++) { shelves.AddRange(GetShelfFaker(Temperatures.Select(x => x.TemperatureId), Restaurants.Select(x => x.RestaurantId)).Generate(1)); } shelves.AddRange(GetShelfFaker(Temperatures.Select(x => x.TemperatureId), Restaurants.Select(x => x.RestaurantId), true).Generate(1)); Shelves = shelves; Couriers = GetCourierFaker(GetFirstNames(), GetLastNames(), Addresses.Select(x => x.AddressId)).Generate(20); Orders = GetOrderFaker(Customers.Select(x => x.CustomerId), Restaurants.Select(x => x.RestaurantId), Addresses.Select(x => x.AddressId), Couriers.Select(x => x.CourierId)).Generate(10); OrderItems = GetOrderItemFaker(MenuItems.Select(x => x.MenuItemId), Orders.Select(x => x.OrderId), Shelves.Select(x => x.ShelfId)).Generate(20); }
public static void AddShelf(string name) { using (ShelvesContext context = new ShelvesContext()) { if (context.Shelves.Where(x => x.Name.ToUpper() == name.Trim().ToUpper()).Count() != 0) { throw new Exception("That shelf already exists."); } // context.Shelves.Add(new Shelves() { Name = name.Trim() }); // context.Add(context.ShelfMaterials.Include(b => b.ID)); var s1 = context.ShelfMaterials.Include(b => b.Shelves).First(); var s2 = new Shelves { Name = name.Trim() }; s1.Shelves.Add(s2); context.SaveChanges(); } }
protected void GridviewBind() { string OLMSDBConnectionString = ConfigurationManager.ConnectionStrings["OLMSDB"].ConnectionString; var OLMSDBConnection = new MySqlConnection(OLMSDBConnectionString); string stackid = Session["STACKID"].ToString(); MySqlCommand get_sql = new MySqlCommand("select ShelfId,Summary,Timestamp from Shelves where StackId='" + stackid + "';"); var resultAdapter = new MySqlDataAdapter(); resultAdapter.SelectCommand = get_sql; resultAdapter.SelectCommand.Connection = OLMSDBConnection; var resultSet = new DataSet(); OLMSDBConnection.Open(); resultAdapter.Fill(resultSet); OLMSDBConnection.Close(); DataTable searchResult = resultSet.Tables[0]; Shelves.DataSource = searchResult; Shelves.DataKeyNames = new string[] { "ShelfId" }; Shelves.DataBind(); if (Shelves.HeaderRow != null) { Shelves.HeaderRow.TableSection = TableRowSection.TableHeader; } }
public void Show() { if (ComponentShelf == null) { try { IDesktopWindow desktopWindow = Context.DesktopWindow; ImagePropertiesApplicationComponent component = new ImagePropertiesApplicationComponent(Context.DesktopWindow); IShelf shelf = ApplicationComponent.LaunchAsShelf(Context.DesktopWindow, component, SR.TitleImageProperties, "ImageProperties", ShelfDisplayHint.DockLeft); Shelves.Add(Context.DesktopWindow, shelf); shelf.Closed += delegate { Shelves.Remove(desktopWindow); }; } catch (Exception e) { ExceptionHandler.Report(e, Context.DesktopWindow); } } else { ComponentShelf.Show(); } }
public void OnTriggerExit(Collider other) { computer = null; desk = null; trashContainer = null; shelves = null; }
public Shelf GetSelectedShelf(int width, int depth, string type) { return(Shelves .Where(x => x.Width == width) .Where(x => x.Depth == depth) .Where(x => x.Type == type) .FirstOrDefault()); }
public void RemoveShelf(Shelf shelf) { var default_shelf = GetDefaultshelf(); var books_to_move = shelf.Books.ToList(); books_to_move.Apply(b => b.Shelf = default_shelf); Shelves.Remove(shelf); }
/// <summary> /// Removes a shelf from the collection /// </summary> public void Remove(Shelf shelf) { TotalPrice -= shelf.Price; TotalQuantity -= shelf.Quantity; if (Shelves.Contains(shelf)) { Shelves.Remove(shelf); } }
public Shelf AddShelf(string name) { var shelf = new Shelf { Name = name }; Shelves.Add(shelf); return(shelf); }
public ShelvesToDb(Shelves shelves) : base(s_metadata) { SetSqlString(0, shelves.LineNumber); SetSqlString(1, shelves.SKU); SetSqlDateTime(2, shelves.ReceiptDate ?? SqlTypes.SqlDateTime.Null); SetSqlDecimal(3, shelves.QtyExpected); SetSqlDecimal(4, shelves.QtyReceived); SetSqlString(5, shelves.Remark); }
public int DifferenceSpace(Shelves firstShelve, Shelves secondShelve) { int diff = FullSpace(firstShelve) - FullSpace(secondShelve); if (diff > 0) { return(diff); } return(diff * -1); }
private void LoadShelves() { Shelf shelf; foreach (string topic in Topics) { shelf = new Shelf(topic); Shelves.Add(shelf); } }
public async Task UpdateShelf(Shelf shelf) { var shelfToUpdate = Shelves.FirstOrDefault(x => x.Symbol == shelf.Symbol); shelfToUpdate.QuantityInStock = shelf.QuantityInStock; shelfToUpdate.Price = shelf.Price; shelfToUpdate.Name = shelf.Name; context.Shelf.Update(shelfToUpdate); await context.SaveChangesAsync(); }
public IActionResult Delete(int id) { Shelves shelves = _unitOfWork.Shelves.GetById(id); if (shelves == null) { return(RedirectToAction(nameof(Index))); } _unitOfWork.Shelves.Delete(shelves); return(RedirectToAction(nameof(Index))); }
private async void DeletShelf(ShelfViewModel vm) { logger.Trace($"Deleting shelf [{vm.Name}]"); var result = (bool)await DialogManager.ShowPromptDialogAsync("Deleting Shelf", "All books on the shelf will be moved to the default shelf.\n\rDo you want to continue"); if (result) { state_manager.CurrentCollection.RemoveShelf(vm.Obj); Shelves.Remove(vm); } }
private void ImportBooks() { var selected_shelves = Shelves.Where(s => s.Selected) .Select(s => s.Name) .ToList(); var books_on_selected_shelves = Books.Where(b => !b.IsDuplicate && selected_shelves.Contains(b.ExclusiveShelf)); var books_to_import = GoodreadsMapper.Map(books_on_selected_shelves).ToList(); import_controller.Import(books_to_import); MessageBus.Current.SendMessage(NavigationMessage.Books); MessageBus.Current.SendMessage(new InformationMessage($"{books_to_import.Count} books were imported")); }
public async Task DeleteShelf(string symbol) { try { var shelfToDelete = Shelves.FirstOrDefault(x => x.Symbol == symbol); context.Shelf.Remove(shelfToDelete); await context.SaveChangesAsync(); } catch (Microsoft.EntityFrameworkCore.DbUpdateException) { return; } }
/// <summary> /// Adds a shelf, that has already been instantiated, to the collection /// </summary> /// <param name="shelf"></param> public void Add(Shelf shelf) { shelf.ColorValues = new ObservableCollection <string>(GetColorValues()); shelf.WidthValues = new ObservableCollection <string>(GetWidthValues()); shelf.DepthValues = new ObservableCollection <string>(GetDepthValues()); shelf.ShelfTypeValues = new ObservableCollection <string>(GetShelfTypeNames()); shelf.viewmodel = this; shelf.Wood.WoodValues = GetWoodValues(); shelf.Banding.BandingValues = GetBandingValues(); TotalQuantity += shelf.Quantity; shelf.PropertyChanged += Shelf_PropertyChanged; Shelves.Add(shelf); }
public void Activate() { IDesktopWindow desktopWindow = this.Context.DesktopWindow; // check if a layout component is already displayed if (Shelves.ContainsKey(desktopWindow)) { Shelves[desktopWindow].Activate(); } else { LaunchShelf(desktopWindow, new CineApplicationComponent(desktopWindow), ShelfDisplayHint.DockFloat); } }
public override async void OnNavigatingTo(NavigationParameters parameters) { base.OnNavigatingTo(parameters); var shelf = await WebClient.Client.ListShelvesAsync(); ObservableCollection <string> temp = new ObservableCollection <string>(shelf); Shelves.Clear(); foreach (string s in temp) { Shelves.Add(s); } }
private static void OnShelfClosed(object sender, ClosedEventArgs e) { // We need to cache the owner DesktopWindow (_desktopWindow) because this tool is an // ImageViewer tool, disposed when the viewer component is disposed. Shelves, however, // exist at the DesktopWindow level and there can only be one of each type of shelf // open at the same time per DesktopWindow (otherwise things look funny). Because of // this, we need to allow this event handling method to be called after this tool has // already been disposed (e.g. viewer workspace closed), which is why we store the // _desktopWindow variable. IShelf shelf = (IShelf)sender; shelf.Closed -= OnShelfClosed; Shelves.Remove(shelf.DesktopWindow); }
private async void AddShelf() { var dialog = new InputDialogViewModel { Title = "Adding Shelf", Message = "Enter name", Hint = "Shelf Name" }; var result = (bool)await DialogManager.ShowInputDialogAsync(dialog); if (result) { var shelf = state_manager.CurrentCollection.AddShelf(dialog.Input); var vm = new ShelfViewModel(shelf); Shelves.Add(vm); } }
private void PopulateData(User friend) { Id = friend.Id; Name = friend.Name; ImageUrl = friend.ImageUrl; Link = friend.Link; Age = friend.Age; About = friend.About; Gender = friend.Gender; Location = friend.Location; Website = friend.Website; Joined = friend.Joined; LastActive = friend.LastActive; Interests = friend.Interests; FavouriteBooks = friend.FavoriteBooks; FriendsCount = $"{friend.FriendsCount} Friends"; BooksCount = $"{friend.ReviewsCount} Books"; GroupsCount = $"{friend.GroupsCount} Groups"; //Task.Run( async () => try { CurrentlyReading.Clear(); if (friend.UserStatuses != null && friend.UserStatuses.Count > 0) { foreach (var userStatus in friend.UserStatuses) CurrentlyReading.Add(new UserStatusViewModel(userStatus)); } Updates.Clear(); if (friend.Updates != null && friend.Updates.Update != null && friend.Updates.Update.Count > 0) { foreach (var userUpdate in friend.Updates.Update) Updates.Add(new UpdateViewModel(userUpdate)); } Shelves.Clear(); if (friend.UserShelves != null && friend.UserShelves.Count > 0) { foreach (var shelf in friend.UserShelves) Shelves.Add(new ShelfViewModel(shelf)); } }//); catch { } }
private async void Add() { if (NewShelf.Trim() != "") { await WebClient.Client.AddNewShelf(NewShelf); NewShelf = ""; var shelf = await WebClient.Client.ListShelvesAsync(); ObservableCollection <string> temp = new ObservableCollection <string>(shelf); Shelves.Clear(); foreach (string s in temp) { Shelves.Add(s); } } }
public static void Test1() { List<string> testBuffer = new List<string> { " - 1 on shelf 1 - ", " - 2 on shelf 1 - ", " - 3 on shelf 2 - ", " - 4 on shelf 2 - ", " - 5 on shelf 2 - ", " - 6 on shelf 3 - ", " - 7 on shelf 3 - ", " - 8 on shelf 4 - ", " - 9 on shelf 4 - ", " - 0 on shelf 10 - "}; IShelves<string> c = new Shelves<string>(); c.Add(1, testBuffer[0]); c.Add(1, testBuffer[1]); c.Add(2, testBuffer[2]); c.Add(2, testBuffer[3]); c.Add(2, testBuffer[4]); c.Add(3, testBuffer[5]); c.Add(3, testBuffer[6]); c.Add(4, testBuffer[7]); c.Add(4, testBuffer[8]); c.Add(10, testBuffer[9]); // output: everything from every shelf int i = 0; foreach (var item in c) { Assert.AreEqual(item[4], testBuffer[i][4]); ++i; } var it = c.GetEnumeratorForLevel(2); i = 0; while (it.MoveNext()) { Assert.AreEqual(it.Current[4], testBuffer[i][4]); ++i; } }
public void OnTriggerStay(Collider other) { if (other.gameObject.CompareTag("Computer")) { computer = other.GetComponent <Computer>(); } if (other.gameObject.CompareTag("Desk")) { desk = other.GetComponent <Desk>(); } if (other.gameObject.CompareTag("TrashContainer")) { trashContainer = other.GetComponent <TrashContainer>(); } if (other.gameObject.CompareTag("Shelves")) { shelves = other.GetComponent <Shelves>(); } }
public decimal CalculateValue(Fridge fridge) { decimal value = Compressors.Where(x => x.Symbol == fridge.CompressorSymbol).SingleOrDefault().Price + Bodies.Where(x => x.Symbol == fridge.BodySymbol).SingleOrDefault().Price; if (fridge.ShelfSet != null && fridge.ShelfSet.Count > 0) { foreach (var shelfSet in fridge.ShelfSet) { value += Shelves.Where(x => x.Symbol == shelfSet.ShelfSymbol) .SingleOrDefault().Price *shelfSet.Quantity; } } if (fridge.HandleSet != null && fridge.HandleSet.Count > 0) { foreach (var handleSet in fridge.HandleSet) { value += Handles.Where(x => x.Symbol == handleSet.HandleSymbol) .SingleOrDefault().Price *handleSet.Quantity; } } if (fridge.BalconySet != null && fridge.BalconySet.Count > 0) { foreach (var balconySet in fridge.BalconySet) { value += Balconies.Where(x => x.Symbol == balconySet.BalconySymbol) .SingleOrDefault().Price *balconySet.Quantity; } } if (fridge.AdditionalSet != null && fridge.AdditionalSet.Count > 0) { foreach (var additionalSet in fridge.AdditionalSet) { value += Additionals.Where(x => x.Symbol == additionalSet.AdditionalEqSymbol) .SingleOrDefault().Price; } } return(value * 1.25M); }
public ImportModuleViewModel(IStateManager state_manager, IImportController import_controller, ApplicationNavigationPartViewModel application_navigation_part, ToolsNavigationPartViewModel tools_navigation_part) { this.state_manager = state_manager; this.import_controller = import_controller; ApplicationNavigationPart = application_navigation_part; ToolsNavigationPart = tools_navigation_part; this.WhenAnyValue(x => x.FullFilename) .Subscribe(x => Filename = Path.GetFileName(x)); OpenFileCommand = ReactiveCommand.Create(OpenFile); var have_imported_books = this.WhenAny(x => x.Books, x => x.Value != null && x.Value.Any()); ImportBooksCommand = ReactiveCommand.Create(ImportBooks, have_imported_books); var have_shelves = this.WhenAny(x => x.Shelves, x => x.Value != null && x.Value.Any()); SelectAllShelvesCommand = ReactiveCommand.Create(() => Shelves.Apply(s => s.Selected = true), have_shelves); DeselectAllShelvesCommand = ReactiveCommand.Create(() => Shelves.Apply(s => s.Selected = false), have_shelves); }
/// <summary> /// Adds a shelf to the collection /// </summary> /// <param name="RoomNumber"></param> /// <param name="Color"></param> /// <param name="SizeDepth"></param> public void Add(int RoomNumber, string Color = null, string SizeDepth = null) { bool HasColor = false; bool HasDepth = false; if (Color != null) { HasColor = true; } HasDepth |= SizeDepth != null; Shelf shelf = new Shelf( RoomNumber, HasColor ? Color : null, HasDepth ? SizeDepth : null) { ColorValues = new ObservableCollection <string>(GetColorValues()), WidthValues = new ObservableCollection <string>(GetWidthValues()), DepthValues = new ObservableCollection <string>(GetDepthValues()), ShelfTypeValues = new ObservableCollection <string>(GetShelfTypeNames()), viewmodel = this }; shelf.Wood.WoodValues = GetWoodValues(); shelf.Banding.BandingValues = GetBandingValues(); TotalQuantity += 1; shelf.PropertyChanged += Shelf_PropertyChanged; if (Color != null) { Color_PropertyChanged(shelf); } Shelves.Add(shelf); }