private ErrorDate checkLevelName(Models.Level newLevel) { List <Models.Level> levels = _context.Level.ToList(); ErrorDate operationOutput = new ErrorDate(); if (levels == null) { operationOutput.Message = null; operationOutput.Name = "Name"; operationOutput.State = true; return(operationOutput); } foreach (var level in levels) { if (level.Name == newLevel.Name) { operationOutput.Message = "Nazwa tego poziomu już istnieje"; operationOutput.Name = "Name"; operationOutput.State = false; return(operationOutput); } } operationOutput.Message = null; operationOutput.Name = "Name"; operationOutput.State = true; return(operationOutput); }
public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { return(Page()); } ErrorField = checkLevelName(Level); if (ErrorField.State == false) { return(Page()); } ErrorField = checkLevelRange(Level); if (ErrorField.State == false) { return(Page()); } _context.Level.Add(Level); await _context.SaveChangesAsync(); return(RedirectToPage("/MenagePanel/Index")); }
private ErrorDate checkLevelRange(Models.Level newLevel) { ErrorDate operationOutput = new ErrorDate(); List <Models.Level> levels = _context.Level.ToList(); foreach (var level in levels) { if (level.BeginOfRange == newLevel.BeginOfRange || level.EndOfRange == newLevel.BeginOfRange) { operationOutput.Message = "Taki przedział już istnieje. Podaj inny."; operationOutput.Name = "BeginR"; operationOutput.State = false; return(operationOutput); } else if (level.BeginOfRange == newLevel.EndOfRange || level.EndOfRange == newLevel.EndOfRange) { operationOutput.Message = "Taki przedział już istnieje. Podaj inny."; operationOutput.Name = "EndR"; operationOutput.State = false; return(operationOutput); } if (newLevel.BeginOfRange > level.BeginOfRange && newLevel.BeginOfRange < level.EndOfRange) { operationOutput.Message = $"Przedział początkowy nie może być w istniejącym przedziale {level.BeginOfRange}-{level.EndOfRange}"; operationOutput.Name = "BeginR"; operationOutput.State = false; return(operationOutput); } if (newLevel.EndOfRange > level.BeginOfRange && newLevel.EndOfRange < level.EndOfRange) { operationOutput.Message = $"Przedział końcowy nie może być w istniejącym przedziale {level.BeginOfRange}-{level.EndOfRange}"; operationOutput.Name = "EndR"; operationOutput.State = false; return(operationOutput); } } if (newLevel.BeginOfRange >= newLevel.EndOfRange) { operationOutput.Message = "Przedział początkowy nie może być większy lub równy od przedziału końcowego"; operationOutput.Name = "BeginR"; operationOutput.State = false; return(operationOutput); } operationOutput.Message = null; operationOutput.Name = "Range"; operationOutput.State = true; return(operationOutput); }
private ErrorDate chechTestFields(Answers answer, string fieldName) { ErrorDate outputModel = new ErrorDate(); if (answer == 0) { outputModel.Name = "test"; outputModel.State = false; outputModel.Message = $"{fieldName} pole jest puste!"; } else { outputModel.Name = "test"; outputModel.State = true; outputModel.Message = $"{fieldName} pole jest poprawne"; } return(outputModel); }
public string GetUrlEncodedText() { var data = "OSVer=" + HttpUtility.UrlEncode(OSVer) + "&ErrorDate=" + HttpUtility.UrlEncode(ErrorDate.ToString("yyyy-MM-dd HH:mm:ss")) + "&DriverVer=" + HttpUtility.UrlEncode(DriverVer) + "&ServiceVer=" + HttpUtility.UrlEncode(ServiceVer) + "&ClientVer=" + HttpUtility.UrlEncode(ClientVer) + "&ErrorID=" + HttpUtility.UrlEncode(ErrorID) + "&ExceptionDetails=" + HttpUtility.UrlEncode(ExceptionDetails) + "&UserActions=" + HttpUtility.UrlEncode(UserActions) + "&email=" + HttpUtility.UrlEncode(Email); if (Log != null) { var eventNumber = 0; for (var i = Log.Entries.Count - 1; i >= 0; i--) { var logEntry = Log.Entries[i]; // Ommit all warnings. if (logEntry.EntryType != EventLogEntryType.Error && logEntry.EntryType != EventLogEntryType.Information) { continue; } data += "&Event" + eventNumber + "=" + HttpUtility.UrlEncode(logEntry.TimeGenerated.ToString("yyyy-MM-dd HH:mm:ss") + "\r\n") + HttpUtility.UrlEncode(logEntry.Message); eventNumber++; if (eventNumber == 10) { break; } } } return(data); }
public string GetUserFriendlyText() { var data = "OSVer=" + OSVer + "\r\nErrorDate=" + ErrorDate.ToString("yyyy-MM-dd HH:mm:ss") + "\r\nDriverVer=" + DriverVer + "\r\nServiceVer=" + ServiceVer + "\r\nClientVer=" + ClientVer + "\r\nErrorID=" + ErrorID + "\r\nExceptionDetails=" + ExceptionDetails + "\r\nUserActions=Text that you entered goes here." + "\r\nemail=email that you entered goes here."; if (Log != null) { var eventNumber = 0; for (var i = Log.Entries.Count - 1; i >= 0; i--) { var logEntry = Log.Entries[i]; // Ommit all warnings. if (logEntry.EntryType != EventLogEntryType.Error && logEntry.EntryType != EventLogEntryType.Information) { continue; } data += "\r\nEvent" + eventNumber + "=" + logEntry.TimeGenerated.ToString("yyyy-MM-dd HH:mm:ss") + "\r\n" + logEntry.Message; eventNumber++; if (eventNumber == 10) { break; } } } return(data); }