public IResponse Execute(ICruiseRequest request) { var velocityContext = new Hashtable(); this.translations = Translations.RetrieveCurrent(); var projectStatus = farmService.GetProjectStatusListAndCaptureExceptions(request.RetrieveSessionToken()); var urlBuilder = request.UrlBuilder; var category = request.Request.GetText("Category"); var gridRows = this.projectGrid.GenerateProjectGridRows(projectStatus.StatusAndServerList, BaseActionName, ProjectGridSortColumn.Category, true, category, urlBuilder, this.translations); var categories = new SortedDictionary <string, CategoryInformation>(); foreach (var row in gridRows) { var rowCategory = row.Category; CategoryInformation categoryRows; if (!categories.TryGetValue(rowCategory, out categoryRows)) { categoryRows = new CategoryInformation(rowCategory); categories.Add(rowCategory, categoryRows); } categoryRows.AddRow(row); } velocityContext["categories"] = categories.Values; return(viewGenerator.GenerateView("CategorizedFarmReport.vm", velocityContext)); }
public async Task AddCategory(CategoryInformation categoryInformation) { var category = _mapper.Map <Category>(categoryInformation); await _context.Categories.AddAsync(category); await _context.SaveChangesAsync(); }
public CategoryInformationForm(CategoryInformation categoryInfo, string title) { InitializeComponent(); this.Text = $"Information - {title}"; this.categoryTitleLabel.Text = title; this.radLabel2.Text = categoryInfo.Information; }
public IResponse Execute(ICruiseRequest request) { var velocityContext = new Hashtable(); this.translations = Translations.RetrieveCurrent(); var projectStatus = farmService.GetProjectStatusListAndCaptureExceptions(request.RetrieveSessionToken()); var urlBuilder = request.UrlBuilder; var category = request.Request.GetText("Category"); var gridRows = this.projectGrid.GenerateProjectGridRows(projectStatus.StatusAndServerList, BaseActionName, ProjectGridSortColumn.Category, true, category, urlBuilder,this.translations); var categories = new SortedDictionary<string, CategoryInformation>(); foreach (var row in gridRows) { var rowCategory = row.Category; CategoryInformation categoryRows; if (!categories.TryGetValue(rowCategory, out categoryRows)) { categoryRows = new CategoryInformation(rowCategory); categories.Add(rowCategory, categoryRows); } categoryRows.AddRow(row); } velocityContext["categories"] = categories.Values; return viewGenerator.GenerateView("CategorizedFarmReport.vm", velocityContext); }
public async Task PostAsync_CategoryIsValid_CategoryShouldBeCreated() { var category = new CategoryInformation { Name = "Fizyka" }; var content = JsonConvert.SerializeObject(category); var stringContent = new StringContent(content, Encoding.UTF8, "application/json"); var response = await _client.PostAsync("/api/category/", stringContent); var readedResponse = await response.Content.ReadAsStringAsync(); var gotGuid = JsonConvert.DeserializeObject <CategoryInformation>(readedResponse); Assert.Equal(HttpStatusCode.OK, response.StatusCode); var responseToGetCategory = await _client.GetAsync("/api/category/1"); responseToGetCategory.EnsureSuccessStatusCode(); var stringResponse = await responseToGetCategory.Content.ReadAsStringAsync(); var gotCattegory = JsonConvert.DeserializeObject <CategoryInformation>(stringResponse); Assert.IsType <CategoryInformation>(gotCattegory); Assert.Equal(gotGuid.CategoryId, gotCattegory.CategoryId); }
public async Task UpdateCategory(CategoryInformation categoryInformation) { var category = _mapper.Map <Category>(categoryInformation); _context.Update(category); await _context.SaveChangesAsync(); }
public async Task <IActionResult> AddCategory(CategoryInformation categoryInformation) { var category = await _validator.ValidateAsync(categoryInformation); if (!category.IsValid) { return(BadRequest(category.Errors)); } await _repository.AddCategory(categoryInformation); return(Ok()); }
public IResponse Execute(ICruiseRequest request) { var velocityContext = new Hashtable(); this.translations = Translations.RetrieveCurrent(); var projectStatus = farmService.GetProjectStatusListAndCaptureExceptions(request.RetrieveSessionToken()); var urlBuilder = request.UrlBuilder; var category = request.Request.GetText("Category"); var sessionToken = request.RetrieveSessionToken(); velocityContext["forceBuildMessage"] = ForceBuildIfNecessary(request.Request, sessionToken); var gridRows = this.projectGrid.GenerateProjectGridRows(projectStatus.StatusAndServerList, BaseActionName, ProjectGridSortColumn.Category, true, category, urlBuilder, this.translations); var categories = new SortedDictionary <string, CategoryInformation>(); foreach (var row in gridRows) { var rowCategory = row.Category; CategoryInformation categoryRows; if (!categories.TryGetValue(rowCategory, out categoryRows)) { categoryRows = new CategoryInformation(rowCategory); categories.Add(rowCategory, categoryRows); } categoryRows.AddRow(row); } // there is a category specified via a link, so expand that category by default // it's annoying to specify a category and still have to press the show link if (!string.IsNullOrEmpty(category)) { categories[category].Display = true; } velocityContext["categories"] = categories.Values; return(viewGenerator.GenerateView("CategorizedFarmReport.vm", velocityContext)); }
public IResponse Execute(ICruiseRequest request) { var velocityContext = new Hashtable(); this.translations = Translations.RetrieveCurrent(); var projectStatus = farmService.GetProjectStatusListAndCaptureExceptions(request.RetrieveSessionToken()); var urlBuilder = request.UrlBuilder; var category = request.Request.GetText("Category"); var sessionToken = request.RetrieveSessionToken(); velocityContext["forceBuildMessage"] = ForceBuildIfNecessary(request.Request, sessionToken); var gridRows = this.projectGrid.GenerateProjectGridRows(projectStatus.StatusAndServerList, BaseActionName, ProjectGridSortColumn.Category, true, category, urlBuilder, this.translations); var categories = new SortedDictionary<string, CategoryInformation>(); foreach (var row in gridRows) { var rowCategory = row.Category; CategoryInformation categoryRows; if (!categories.TryGetValue(rowCategory, out categoryRows)) { categoryRows = new CategoryInformation(rowCategory); categories.Add(rowCategory, categoryRows); } categoryRows.AddRow(row); } // there is a category specified via a link, so expand that category by default // it's annoying to specify a category and still have to press the show link if (!string.IsNullOrEmpty(category)) { categories[category].Display = true; } velocityContext["categories"] = categories.Values; return viewGenerator.GenerateView("CategorizedFarmReport.vm", velocityContext); }
/// <summary> /// Converts from the user input data to the target unit and applies appropriate /// formatting to the converted value /// </summary> /// <param name="sourceUnitValue">Value to be converted to the target unit</param> private void ConvertAndDisplayTargetUnit(double sourceUnitValue) { double convertedValue = 0.0; convertedValue = CategoryInformation.Convert( sourceUnitValue, this.ConversionSettings.SourceUnit, this.ConversionSettings.TargetUnit); string potentialConvertedText = string.Empty; // Regardless of value, just try and fit the text on the screen, if it works we don't // need to use scientific notation otherwise we do potentialConvertedText = convertedValue.ToString(completeFormat, ApplicationState.CurrentCulture); if (potentialConvertedText.Length > MaximumNumberOfInputDigits) { const double StandardDisplayLarge = 1.0e11; // two less available spaces for decimal and zero const double StandardDisplaySmall = 1.0e-9; const string ScientificNotationFormat = "0.{0}e-0"; const string RegularNotationFormat = "0.{0}"; string notationFormat = RegularNotationFormat; if (Math.Abs(convertedValue) >= StandardDisplayLarge || Math.Abs(convertedValue) <= StandardDisplaySmall) { notationFormat = ScientificNotationFormat; } int numDecimalPlaces = potentialConvertedText.Length; string decimalSpecifier = new string('#', numDecimalPlaces); for (; numDecimalPlaces > 0 && potentialConvertedText.Length > MaximumNumberOfInputDigits; --numDecimalPlaces) { // Strip off one of the #s, we need to lose some precision to fit. decimalSpecifier = decimalSpecifier.Remove(0, 1); string format = string.Format(CultureInfo.CurrentCulture, notationFormat, decimalSpecifier); potentialConvertedText = convertedValue.ToString(format, ApplicationState.CurrentCulture); } } this.AssignUnitValue(false, potentialConvertedText); }
/// <summary> /// Restores the user selections. This can be used when we are navigating from /// the main page, or are returning from a tombstone operation. /// </summary> internal static void RestoreUserSelections() { CategoryPageState p = ApplicationState.CategoryPageInformation; // If we are on the favorite tab, we handle the data binding differently if (p.IsFavorite) { return; } // In case the user does not make any changes or selections, we need to have the data // to send back to the main page, so we select the current conversion units CategoryInformation c = ApplicationState.UnitCategoryAccess[p.Category]; try { if ((p.SourceUnitName != null) && (c.PivotUnitSelect.fromListView.ItemsSource != null)) { c.PivotUnitSelect.fromListView.SelectedItem = c.FindUnit(p.SourceUnitName); } else { c.PivotUnitSelect.fromListView.SelectedIndex = -1; } if ((p.TargetUnitName != null) && (c.PivotUnitSelect.toListView.ItemsSource != null)) { c.PivotUnitSelect.toListView.SelectedItem = c.FindUnit(p.TargetUnitName); } else { c.PivotUnitSelect.toListView.SelectedIndex = -1; } } catch (Exception e) { ApplicationState.ErrorLog.Add(new ErrorLog("RestoreUserSelections", e.Message)); c.PivotUnitSelect.fromListView.SelectedIndex = -1; c.PivotUnitSelect.toListView.SelectedIndex = -1; } }
/// <summary> /// Syncs the state of selections on this page to the main application state /// objetc. THis will be used for either Tombstone support, or returning to the main /// application page /// </summary> /// <param name="pivotIndex">Index of the page in the pivot control</param> internal void SyncStateToAppState(Int32 pivotIndex) { CategoryPageState c = ApplicationState.CategoryPageInformation; ApplicationState.CategoryPageInformation.PivotSelectedIndex = pivotIndex; // We may have an invalid unit category if we chose a favorite and then deleted // it, in which case the user has not made a selection. We will set the // apply flag to false so that the main page will not try to apply the settings // from this page. if (!String.IsNullOrEmpty(c.Category)) { // Favorite category is not in the list of supported categories, because // it is not in the XML file. if (ApplicationState.UnitCategoryAccess.ContainsKey(c.Category)) { // Non favorite category selection CategoryInformation category = ApplicationState.UnitCategoryAccess[c.Category]; // We only set the selection information back on the app for use on the main // page if it's valid. The user must have chosen an item for the to and from // unit list on the same category. // Our category is only updated once we've made a selection // in both the to/from list boxes in order // for the main page to update the conversion information if (!(category.IsUnit(c.SourceUnitName) && category.IsUnit(c.TargetUnitName))) { // The unit selections are not both valid. Don't apply any change c.Apply = false; } } else { // Favorite category case c.Apply = this.lastSelectedFavorite != null ? true : false; } } else { c.Apply = false; } }
public async Task <IActionResult> UpdateCategory(CategoryInformation categoryInformation) { await _repository.UpdateCategory(categoryInformation); return(Ok()); }
static void Main(string[] args) { Console.WriteLine("Initializing API..."); HF_API api = new HF_API("", "HF-Sharp"); // Use this if you're running your program on a server or VPN. // The parameter passed to 'BypassCaptchaSystem' should be a 2Captcha API Key. /*Console.WriteLine("Bypassing captcha system..."); * api.BypassCaptchaSystem("");*/ Console.WriteLine("\nTesting GetVersion..."); Console.WriteLine("Completed. Version #" + api.GetVersion()); Console.WriteLine("\nTesting GetUserInformation..."); UserInformation user = api.GetUserInformation(3241222); Console.WriteLine("username: "******"\nTesting GetCategoryInformation..."); CategoryInformation category = api.GetCategoryInformation(151); Console.WriteLine("category name: " + category.Name); Console.WriteLine("\nTesting GetForumInformation..."); ForumInformation forum = api.GetForumInformation(208); Console.WriteLine("forum name: " + forum.Name); Console.WriteLine("\nTesting GetThreadInformation..."); ThreadInformation thread = api.GetThreadInformation(5665556); Console.WriteLine("thread name: " + thread.Subject); Console.WriteLine("\nTesting GetPostInformation..."); PostInformation post = api.GetPostInformation(58564495); Console.WriteLine("post message: " + post.Message); Console.WriteLine("\nTesting GetPrivateMessageContainer..."); PrivateMessageContainer privateMessageContainer = api.GetPrivateMessageContainer(); Console.WriteLine("box information: " + privateMessageContainer.ContainerName + ", " + privateMessageContainer.PageInfo.TotalMessages + " messages"); Console.WriteLine("\nTesting GetPrivateMessages..."); List <PrivateMessageInformation> messages = api.GetPrivateMessages(); Console.WriteLine("got messages: " + messages.Count + " total, first id: " + messages[0].ID); Console.WriteLine("\nTesting GetPrivateMessage..."); PrivateMessage message = api.GetPrivateMessage(messages[0].ID); Console.WriteLine("got message: from " + message.FromUsername + ", to " + message.ToUsername + ", subject = " + message.Subject); Console.WriteLine("\nTesting GetGroupInformation..."); GroupInformation group = api.GetGroupInformation(52); Console.WriteLine("group: " + group.Name + ", owner: " + group.Owner.Username); Console.ReadKey(); }