private bool ValidateMenuOnUpdate(Menu menu) { var validated = true; using (var context = UnitOfWork.Factory.Instance()) { if (context.Menus.NameAlreadyUsed(menu.Id, txtMenuName.Text)) { validated = SetErrorMessage(txtMenuName, MessageHelper.DuplicateRecord(txtMenuName.Text)); } if (context.Menus.AcronymAlreadyUsed(menu.Id, txtMenuAcronym.Text)) { validated = SetErrorMessage(txtMenuAcronym, MessageHelper.DuplicateRecord(txtMenuAcronym.Text)); } } if (string.IsNullOrEmpty(txtMenuName.Text.Trim())) { validated = SetErrorMessage(txtMenuName, MessageHelper.NoInput()); } if (string.IsNullOrEmpty(txtMenuAcronym.Text.Trim())) { validated = SetErrorMessage(txtMenuAcronym, MessageHelper.NoInput()); } return(validated); }
private void FillMenuDetails(Menu menu) { txtMenuName.Text = menu.Name; txtMenuAcronym.Text = menu.Acronym; txtMenuPrice.Text = menu.Price.ToString(); cbMenuCategory.SelectedValue = menu.CategoryId; cbMenuAvailability.Checked = menu.Availability; pbAccount.Image = string.IsNullOrEmpty(menu.MenuImage) ? Properties.Resources.Default_100 : PathHelper.GetImage(menu.MenuImage); }