Exemplo n.º 1
0
        public string NumericSeqResult(int number)
        {
            var sb = new StringBuilder();

            try
            {
                sb.AppendLine("<div class=\"alert \">");
                sb.AppendFormat("<strong>Number series:</strong> {0}", number.GenerateNumberSeries().ToCommaDelimitedText());
                sb.AppendLine("</div>");

                sb.AppendLine("<div class=\"alert alert-info\">");
                sb.AppendFormat("<strong>Even Number series</strong>: {0}", number.GenerateEvenNumberSeries().ToCommaDelimitedText());
                sb.AppendLine("</div>");

                sb.AppendLine("<div class=\"alert alert-warning\">");
                sb.AppendFormat("<strong>Odd Number series:</strong> {0}", number.GenerateOddNumberSeries().ToCommaDelimitedText());
                sb.AppendLine("</div>");

                sb.AppendLine("<div class=\"alert alert-danger\">");
                sb.AppendFormat("<strong>Multiple of 3,5 and both 3 and 5 series:</strong> {0}", number.GenerateNumberSeries().ToCommaDelimitedTextParseMultiplesOf3And5());
                sb.AppendLine("</div>");

                sb.AppendLine("<div class=\"alert alert-danger\">");
                sb.AppendFormat("<strong>Fibonacci Series:</strong> {0}", number.GenerateFibonacciSeries().ToCommaDelimitedText());
                sb.AppendLine("</div>");
            }
            catch (Exception ex)
            {
                _logger.LogError(ex.Message);
                throw;
            }

            return(sb.ToString());
        }
Exemplo n.º 2
0
 public ActionResult GetNumberSeries(Numbers numbers)
 {
     try
     {
         if (ModelState.IsValid)
         {
             ViewBag.Message = _noSeqCalculatorService.NumericSeqResult(numbers.Number);
         }
         return(View("index"));
     }
     catch (Exception ex)
     {
         _logger.LogError(ex.Message);
         return(View("Index"));
     }
 }
Exemplo n.º 3
0
 private static void LogApplicationException(string exceptionMsg)
 {
     _logger.LogError(exceptionMsg);
 }