private void AddHistory() { MenuHistory.Add(this); if (MenuHistory.Count > MaxHistoryCount) { MenuHistory.RemoveAt(0); } }
public Menu Update(MenuDTO dto, long userId) { using (var transac = new TransactionScope()) { var date = DateTime.UtcNow; var exist = Manager.Query.Value.Get().FirstOrDefault(s => s.MenuId == dto.MenuId); if (exist == null) { throw new Exception("Your menu doesn't exist"); } else { if (exist.Price != dto.Price) { var newMenuHistory = new MenuHistory { MenuCode = exist.MenuCode, MenuType = exist.MenuType, Name = exist.Name, Address = exist.Address, CreatedBy = userId, CreatedDate = date, UpdatedBy = userId, UpdatedDate = date, Price = exist.Price }; Manager.Database.MenuHistories.Add(newMenuHistory); } exist.MenuCode = dto.MenuCode; exist.MenuType = dto.MenuType; exist.Name = dto.Name; exist.Address = dto.Address; exist.UpdatedBy = (int)userId; exist.UpdatedDate = date; exist.Price = dto.Price; Manager.Database.SaveChanges(); } transac.Complete(); return(exist); } }
public IEnumerable <MenuIngredientModel> Resolve(MenuHistory source, ExtendedMenuModel destination, IEnumerable <MenuIngredientModel> destMember, ResolutionContext context) { return(source.Items .SelectMany(i => i.Recipe.RecipeIngredients) .Select(x => new MenuIngredientModel { Id = x.IngredientId, Name = x.Ingredient.Name, Type = x.Ingredient.Type, UnitCategory = x.Unit.UnitCategory, Amount = x.Amount * x.Unit.Coefficient }) .GroupBy(x => x.Id) .Select(x => x.Aggregate((a, b) => { a.Amount += b.Amount; return a; }))); }
protected void ShowPreviousMenu(BaseUI <T> exceptUI = null) { if (exceptUI != null) // exceptUI는 제외 menuHistory에서 제거하자. { MenuHistory.RemoveAll(x => x == exceptUI); } int lastIndex = MenuHistory.Count - 1; if (lastIndex == -1) { Debug.Log("보여줄 메뉴가 없다"); return; } var previousMenu = MenuHistory[lastIndex]; MenuHistory.RemoveAt(lastIndex); previousMenu.Show(); }
public int SubmitMenu(string menuName) { var currentUserId = this._currentUser.UserId; var userMenu = this._dbContext.UserMenus .Where(x => x.UserId == this._currentUser.UserId) .ToList(); var menuHistory = new MenuHistory { MenuName = menuName, UserId = currentUserId, RecipeCount = userMenu.Count, Items = userMenu.Select(x => new MenuRecipe { RecipeId = x.RecipeId }).ToList(), CreatedTime = DateTime.Now }; this._menuHistoryRepository.Add(menuHistory); this._dbContext.UserMenus.RemoveRange(userMenu); this.SaveChanges(); return(menuHistory.Id); }