The Code for RoundAbout

The Model

            
  namespace RoundAboutMVC.Models
{
    public class RoundAbout
    {
        public int RoundValue { get; set; }
        public int AboutValue { get; set; }
        public int StartValue { get; set; }
        public int EndValue { get; set; }
        public string FirstWord { get; set; }
        public string LastWord { get; set; }

        public List<string> Result { get; set; } = new();
    }
}

                
            

The View



<form asp-controller="Home" id="raForm" asp-action="FBPage" method="post" class="row row-cols-1 row-cols-lg-2 gy-2 gx-3">
    <div class="col">
        <label>Enter the starting number.</label>
        <input id="startValue" asp-for="StartValue" min="1" max="100" type="number" class="form-control" placeholder="Start Value" value="@Model.StartValue" aria- label="Start Value">
    </div>
    <div class="col">
        <label>Enter the ending number.</label>
        <input id="endValue" asp-for="EndValue" min="1" max="100" type="number" class="form-control" placeholder="Start Value" value="@Model.EndValue" aria- label="End Value">
    </div>
    <div class="col">
        <label>Enter the first word.</label>
        <input id="firstWord" asp-for="FirstWord" type="text" class="form-control" placeholder="First Word" value="@Model.FirstWord" aria- label="First Word">
    </div>
    <div class="col">
        <label>Enter the second word.</label>
        <input id="secondWord" asp-for="LastWord" type="text" class="form-control" placeholder="Second Word" value="@Model.LastWord" aria- label="Second Word">
    </div>
    <div class="col">
        <label>Enter the multiple(number) you want replaced by the first word.</label>
        <input id="roundValue" asp-for="RoundValue" type="number" class="form-control" placeholder="Round Value" value="@Model.RoundValue" aria- label="Round Value">
    </div>
    <div class="col">
        <label>Enter the multiple(number) you want replaced by the second word.</label>
        <input id="roundValue" asp-for="AboutValue" type="number" class="form-control" placeholder="Round Value" value="@Model.AboutValue" aria- label="Round Value">
    </div>
        <div class="input-group col-12 col-lg-12 d-flex justify-content-start justify-content-lg-end">
        <div class="input-group-append">
        <button type="submit" id="btnSubmit" class="btn btn-dark btn-lg">Display RoundAbout</button>
        </div>
    </div>
</form>
<h2 class="mt-5 border-bottom border-2">Results</h2>
<table class="table table-striped table-sm">
<tbody id="results">
    <!-- results go here -->
                @if (@Model.Result.Count > 0)
                {
    <table class="table table-striped table-hover table-dark">
    <thead><tr><th class="colspan=5">Results</th></tr></thead>
    <tbody>
                            @for (int i = 0; i < Model.Result.Count(); i++)
                            {
        <tr><td>@Model.Result[i]</td></tr>
                            }
                </tbody>
            </table>   
                }
</tbody>
</table>
                
            

The Controller

            
[HttpGet]
public IActionResult FBPage()
{
    RoundAbout model = new();
    model.RoundValue = 3;
    model.AboutValue = 5;
    model.StartValue = 1;
    model.EndValue = 100;
    model.FirstWord = "Round";
    model.LastWord = "About";

    return View(model);
}

[HttpPost]
[ValidateAntiForgeryToken]
public IActionResult FBPage(RoundAbout roundAbout)
{
    List<string> raItems = new();
    bool round;
    bool about;

    for (int i = roundAbout.StartValue; i <= roundAbout.EndValue; i++)
    {
        round = (i % roundAbout.RoundValue == 0);
        about = (i % roundAbout.AboutValue == 0);

        if (round == true && about == true)
        {
            raItems.Add($"{ roundAbout.firstWord}{roundAbout.LastWord}");
        }
        else if (round == true)
        {
            raItems.Add(roundAbout.firstWord);
        }
        else if (about == true)
        {
            raItems.Add(roundAbout.LastWord);
        }
        else
        {
            raItems.Add(i.ToString());
        }
    }

    roundAbout.Result= raItems;

    return View(roundAbout);
}

                
            

This code is structured using the MVC model.

The Model

The model represents the database. It defines the database table as well as the columns. The perameters are set in the class, and translated into SQL on the server side.

The View

The view is a web page that displays the data and is the interface between the user and the applicaiton. It uses a combination of HTML, CSS, Javasctipt and C# to display the web page.

The Controller

When the view, or web page is interacted with by the user, the controller is consulted to determine the action to be taken. In this case, the user enters data in a form, and when the button is clicked, the controller executes the appropriate action determined by the code. It communicates between the model and the view. The controller also exectues any commands on the back end database as dictated by the code. In this example, the controller recieves the data entered in the form, executes the function to process the data entered, communicates with the database to make the designated changes, then sends the result back to the view and displays it.

Please contact me if you have any questions and/or would like to discuss my skill set and qualifications.