how to create due date calculator in asp.net mvc c#

How to create due date calculator in asp.net mvc c#

In .cshtml page

@{
    ViewBag.Title = "Due Date Calculator - Check Your Pregnancy Date Now";
    ViewBag.Description = "Due Date Calculator - When is your due date? How many weeks are you supported your due date? Use our due date calculator to estimate by your last period how far along are you. Pregnancy calculator. mc";
    }
@*<div class="jumbotron">
    <h1></h1>
</div>*@
<div class="row">
    <div class="col-md-8">
        <div class="blog-masonry ddpadding-3">
            <div class="col-lg-12 ddpadding-3">
                <div class="blog-carousel ddpadding-0">
                    <div class="col-lg-12" style="background-color: #F5F5F5;">
                        <section>
                            <div class="form-row">
                                <div class="form-group col-md-12" style="background-color:#474b83">
                                    <div class="container">
                                        <div class="col-lg-12">
                                            <h1 class="h2 nopadding ddheading" style="color: #fff; margin-top: 20px;">Due Date Calculator</h1>
                                        </div>
                                    </div>
                                </div>
                                <div class="col-lg-12 text-center">
                                    <p>Enter the first day of your last menstrual period, then press 'Calculate.</p>
                                </div>
                                <div class="form-group mx-sm-4 mb-3">
                                    <select name="ddlMonth" id="ddlMonth" class="form-control" required="true">
                                        <option value="0">Select Month</option>
                                        <option value="01">January</option>
                                        <option value="02">February</option>
                                        <option value="03">March</option>
                                        <option value="04">April</option>
                                        <option value="05">May</option>
                                        <option value="06">June</option>
                                        <option value="07">July</option>
                                        <option value="08">August</option>
                                        <option value="09">September</option>
                                        <option value="10">October</option>
                                        <option value="11">November</option>
                                        <option value="12">December</option>
                                    </select>
                                </div>
                                <div class="form-group mx-sm-4 mb-3">
                                    <select name="ddlDay" id="ddlDay" class="form-control" required="true">
                                        <option value="0">Select Day</option>
                                        <option value="01">1</option>
                                        <option value="02">2</option>
                                        <option value="03">3</option>
                                        <option value="04">4</option>
                                        <option value="05">5</option>
                                        <option value="06">6</option>
                                        <option value="07">7</option>
                                        <option value="08">8</option>
                                        <option value="09">9</option>
                                        <option value="10">10</option>
                                        <option value="11">11</option>
                                        <option value="12">12</option>
                                        <option value="13">13</option>
                                        <option value="14">14</option>
                                        <option value="15">15</option>
                                        <option value="16">16</option>
                                        <option value="17">17</option>
                                        <option value="18">18</option>
                                        <option value="19">19</option>
                                        <option value="20">20</option>
                                        <option value="21">21</option>
                                        <option value="22">22</option>
                                        <option value="23">23</option>
                                        <option value="24">24</option>
                                        <option value="25">25</option>
                                        <option value="26">26</option>
                                        <option value="27">27</option>
                                        <option value="28">28</option>
                                        <option value="29">29</option>
                                        <option value="30">30</option>
                                        <option value="31">31</option>
                                    </select>
                                </div>
                                <div class="form-group mx-sm-4 mb-3">
                                    <select name="ddlYear" id="ddlYear" class="form-control" required="true">
                                        <option value="0">Select Year</option>
                                        <option value="@DateTime.Now.AddYears(-1).Year">@DateTime.Now.AddYears(-1).Year</option>
                                        <option value="@DateTime.Now.Year">@DateTime.Now.Year</option>
                                    </select>
                                </div>
                                <div class="form-group mx-sm-3 mb-3">
                                    <input type="submit" name="btnDDCCalculate" value="Calculate" id="btnDDCCalculate" class="btn btn-danger">
                                </div>
                            </div>
                        </section>
                        <section style="background-color: #fff;">
                            <div class="table-responsive">
                                <table class="table dtableheading table-hover table-striped table-bordered time" style="display:none;" id="tbl_Duedatecal">
                                    <tbody>
                                        <tr class="bg-primary text-light text-center">
                                            <th colspan="2"><span> Due Date Calculated Result</span></th>
                                        </tr>
                                        <tr>
                                            <td>
                                                Conception likely occurred around: <br>
                                                (Approximately two weeks after your last menstrual period)
                                            </td>
                                            <td class="text-center">
                                                <div><strong><span class="text-primary" id="txt2Weeks"></span></strong></div>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td>
                                                Period of greatest risk for birth defects: <br>
                                                Five to ten weeks gestational age (number of weeks since your last menstrual period)
                                            </td>
                                            <td class="text-center">
                                                <div><strong><span class="text-primary" id="txt5To10"></span></strong></div>
                                                <br><span>To</span><br>
                                                <div><strong><span class="text-primary" id="txtFiveToTenWeeks"></span></strong></div>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td>Beginning of organ formation (Five Weeks Gestational Age):</td>
                                            <td class="text-center">
                                                <div><strong><span class="text-primary" id="txtFiveWeeks"></span></strong></div>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td>Major organs have formed (Ten Weeks Gestational Age):</td>
                                            <td class="text-center">
                                                <div><strong><span class="text-primary" id="txtTenWeeks"></span></strong></div>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td>End of first trimester(12 weeks) - Risk of miscarriage decreases: <br> (11 to 14 Weeks Gestational Age)</td>
                                            <td class="text-center">
                                                <div><strong><span class="text-primary" id="txt12Weeks"></span></strong></div>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td>Some preemies can now survive (23 Weeks Gestational Age):</td>
                                            <td class="text-center">
                                                <div><strong><span class="text-primary" id="txt23Weeks"></span></strong></div>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td>End of second trimester (27 weeks):</td>
                                            <td class="text-center">
                                                <div><strong><span class="text-primary" id="txt27Weeks"></span></strong></div>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td>Estimated due date(40 weeks - full term):</td>
                                            <td class="text-center">
                                                <div><strong><span class="text-primary" id="txt40Weeks"></span></strong></div>
                                            </td>
                                        </tr>
                                    </tbody>
                                </table>
                                <div class="row">
                                    <div class="card">
                                        <div class="card-body">

                                            <div class="form-row col-md-12">
                                                <div class="form-group col-md-4">
                                                    <img src="/images/Pregnancy-Due-Date.png" alt="Pregnancy Due Date Calculator" style="max-height:121px;" />
                                                </div>
                                                <div class="form-group col-md-8">
                                                    <p style="text-align:justify">
                                                        Use seotoolsrack.com physiological state due date Calculator to estimate your baby's maturity date supported the primary day of your last amount, the date you planned and different ways.
                                                        Your health care provider uses the number of weeks since your last menstrual period to describe how far along you are in your pregnancy.
                                                    </p>
                                                </div>
                                            </div>
                                            <h2 class="h4"><strong> Do you calculate your due date?</strong></h2>
                                            <p style="text-align:justify">
                                                A typical physiological state lasts, on average, 280 days, or forty weeks--starting with the primary day of the last traditional emission amount (LMP) as day one.
                                                An calculable maturity date (EDD) will be calculated <b> by following steps:</b>
                                            </p>
                                            <ul>
                                                <li>1. First, verify the primary day of your last emission amount.</li>
                                                <li>2. Next, count back 3 calendar months from that date.</li>
                                                <li>3. Lastly, add one year and seven days to that date.</li>
                                            </ul>
                                            <h2 class="h4"><strong>When did conceive?</strong></h2>
                                            <p style="text-align:justify">Conception usually occurs around 11-21 days after the first day of the last period of a woman who has a regular period. The estimation of conception date is based on this, but is rarely ever exact since it is difficult to know exactly when ovulation occurs.</p>
                                            <br />
                                            <h2 class="h4"><strong>How do you calculate EDD?</strong></h2>
                                            <p style="text-align:justify">EDD by LMP is calculated by adding 280 days (40 weeks) to the primary day of the last emission amount.</p>
                                            <br />
                                            <h2 class="h4"><strong>Why do doctors add 2 weeks to pregnancy?</strong></h2>
                                            <p style="text-align:justify">Your <strong>pregnancy due date</strong> is based on your last menstrual period, so that would put it about two weeks off from your conception date. While physiological state is truly nine 1/2 months, doctors calculate it as ten months as a result of they add those period in before conception.</p>
                                            <br />
                                            <h2 class="h4"><strong>How are you able to tell the precise date you bought pregnant?</strong></h2>
                                            <p style="text-align:justify">
                                                So, if you recognize once your amount was due, count back period to search out your biological process date.
                                                This is most likely to be when you conceived.
                                                If you had sex within the 5 days before biological process, your partner's sperm may have been ready and waiting for the egg when it was released.
                                            </p>
                                            <br />
                                            <h3 class="h4"><strong>Can due date change?</strong></h3>
                                            <p style="text-align:justify">
                                                Your doctor might modification your maturity date supported the ultrasound activity.
                                                This is presumably to occur within the trimester, especially if the date estimated by the ultrasound differs by more than one week from the date estimated by your doctor based on your LMP.
                                            </p>
                                            <br />
                                            <h3 class="h4"><strong>Why due date calculation is important?</strong></h3>
                                            <p style="text-align:justify">A hopeful mother excitedly hangs tight for the entry of the child. The <strong> due date</strong> is significant as it tells the date of your conveyance. It causes her to be physically just as rationally arranged and furthermore to keep a track on the advancement of her conveyance.</p>
                                            <br />
                                            <h4 class="h4"><strong>When to see a doctor?</strong></h4>
                                            <p style="text-align:justify">Once you find your pregnancy test positive, it is important to go for an antenatal check up.</p>
                                            <br />
                                            <h5 class="h4"><strong>Determining the Estimated Due Date</strong></h5>
                                            <p style="text-align:justify">The <a href="https://en.wikipedia.org/wiki/Estimated_date_of_delivery" target="_blank"> <strong>Estimated Due Date (EDD or EDC)</strong> (wikipedia.org)</a> is the date that unconstrained beginning of work is relied upon to happen. The due date might be evaluated by including 280 days ( 9 months and 7 days) to the main day of the <strong>last menstrual period (LMP)</strong>. This is the strategy utilized by "pregnancy wheels". The exactness of the EDD determined by this strategy relies upon precise review by the mother, expect ordinary multi day cycles, and that ovulation and origination happens on day 14 of the cycle. Utilization of the LMP to set up the due date may overestimate the term of the pregnancy, and can be dependent upon a mistake of over about fourteen days 5-7.</p>
                                            <br />
                                            <p style="text-align:justify">In situations where the date of origination is referred to exactly, for example, with in vitro treatment, the EDD is determined by adding 266 days to the date of origination.</p>
                                            <br />
                                            <p style="text-align:justify">Ultrasound utilizes the size of the embryo to decide the gestational age (the time passed since the main day of the last menstrual period). The exactness of the ultrasound gauge of the gestational age differs as per the gestational age. "Ultrasound estimation of the incipient organism or embryo in the principal trimester (up to and including 13 6/7 weeks of incubation) is the most precise strategy to build up or affirm physiological condition age" twenty four.The Society of Obstetricians and Gynecologists of Canada prescribes the soonest ultrasound with a crown posterior length identical to at any rate 7 weeks (or 10 mm) ought to be utilized to decide the gestational age 28.</p>
                                            <br />
                                            <p style="text-align:justify">The <a href="https://www.acog.org/?IsMobileSet=false" target="_blank"> american college of obstetricians and gynecologists (acog.org)</a> suggests that ultrasound-built up dates should take inclination over menstrual dates when the disparity between ultrasound dating and lmp is</p>
                                            <ul>
                                                <li>1. Greater than 5 days before 9 0/7 weeks of gestation by LMP</li>
                                                <li>2. Greater than 7 days from 9 0/7 weeks to 15 6/7 weeks by LMP</li>
                                                <li>3. Greater than 10 days from 16 0/7 weeks to 21 6/7 weeks by LMP</li>
                                                <li>4. Greater than 14 days from 22 0/7 weeks to 27 6/7 weeks by LMP</li>
                                                <li>5. Greater than 21 days after 28 0/7 weeks by LMP</li>
                                            </ul>
                                            <p style="font-style:italic"><b>Example:</b><br />LMP = 8 May 2009</p>
                                            <ul>
                                                <li>&nbsp; +1 year = 8 May 2010</li>
                                                <li>&nbsp; −3 months = 8 February 2010</li>
                                                <li>&nbsp; +7 days = 15 February 2010</li>
                                                <li>
                                                    280 days past the beginning of the last emission amount is found by checking the day of the week of the LMP and adjusting the calculated date to land on
                                                    the same day of the week.
                                                    Using the instance on top of, 8 May 2009 is a Friday.
                                                    The calculated date (15 Feb) could be a Monday; adjusting to the nighest weekday produces twelve February, which is exactly 280 days past 8 May.
                                                    The calculation methodology doesn't forever end in 280 days as a result of not all calendar months area unit identical length; it doesn't account for leap years.
                                                </li>
                                            </ul>

                                            <p style="text-align:justify">In view of the danger of redating a little embryo that might be development limited, the executives choices dependent on third-trimester ultrasonography alone are particularly tricky; they should be guided via cautious thought of the whole clinical picture and may require nearer reconnaissance, including rehash ultrasonography to guarantee fitting interim development.</p>
                                            <br />
                                            <h2 class="h4"><strong>Have a healthy diet</strong></h2>
                                            <p style="text-align:justify">The underlying stage is the most critical phase of your pregnancy. The correct sort of eating routine at the underlying stage greatly affects the hatchling. You should eat nutritious nourishment for sound advancement of the infant in your belly.</p>
                                            <ul>
                                                <li><strong>1. Eat foods enriched with fibre</strong></li>
                                                <li><strong>2. Avoid skipping meals, especially breakfast</strong></li>
                                                <li><strong>3. As advised by your gynae, eat appropriate amounts of folic acid and iron</strong></li>
                                                <li><strong>4. If hungry, binge on healthy snacks</strong></li>
                                            </ul>
                                            <h2 class="h4"><strong>Things to keep away from</strong></h2>
                                            <p style="text-align:justify">It is ideal to maintain a strategic distance from all exercises that may put your <strong> pregnancy in danger</strong>. Specialists prompt for exercise (under the supervision of an expert), strolling and remaining dynamic all through the pregnancy. Be that as it may, you should stay away from the accompanying:</p>
                                            <ul>
                                                <li><strong>1. Running</strong></li>
                                                <li><strong>2. Diving</strong></li>
                                                <li><strong>3. Water skiing</strong></li>
                                                <li><strong>4. Jumping</strong></li>
                                                <li><strong>5. Hot tubs and saunas</strong></li>
                                                <li><strong>6. Amusement park rides</strong></li>
                                            </ul>
                                            <h3 class="h4"><strong> More precautions</strong></h3>
                                            <p style="text-align:justify">There are several foods that are strictly prohibited for the would-be-mother. These include:</p>
                                            <ul>
                                                <li><strong>1. Medications (without prescription)</strong></li>
                                                <li><strong>2. Excess intake of caffeine</strong></li>
                                                <li><strong>3. Food additives</strong></li>
                                                <li><strong>4. Smoking</strong></li>
                                                <li><strong>5. Alcohol</strong></li>
                                            </ul>
                                            <p style="text-align:justify">All that you expend or you do, straightforwardly sway the development of your baby. Consequently, it is significant that your eating routine and the exercises ought to be sound. Try not to miss any arrangement as this is a basic period of your life.</p>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </section>
                    </div>
                </div>
            </div>
        </div>
    </div>


<div class="col-md-4">
    <div class="widget">
        <div class="card" style="">
            <div class="card-body">
                <script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
                <!-- displayaddsquare -->
                <ins class="adsbygoogle"
                     style="display:block"
                     data-ad-client="ca-pub-5064107117435206"
                     data-ad-slot="5609541757"
                     data-ad-format="auto"
                     data-full-width-responsive="true"></ins>
                <script>
                    (adsbygoogle = window.adsbygoogle || []).push({});
                </script>

                <h5 class="card-title card-footer">Recent Posts</h5>
                <ul id="ulRecentPosts">
                </ul>
            </div>
        </div>
    </div>
</div>
</div>

[HttpGet]
        [Route("due-date-calculator")]
        public ActionResult duedatecalculator()
        {
            return View();
        }
        [HttpGet]
        public JsonResult duedatecalculator(string ddlMonth, string ddlDay, string ddlYear)
        {
            var list = new List<dynamic>();
            try
            {
                string strMonth = string.Empty;
                int iMnt = 0;
                int iday = 0;
                int year = 0;
                string strYear = string.Empty;
                //string ddlMonth = frm["ddlMonth"];
                // string ddlDay = frm["ddlDay"];
                strYear = ddlYear;// frm["ddlYear"];
                strMonth = ddlMonth;// frm["ddlMonth"];
                year = Convert.ToInt32(strYear);
                iMnt = Convert.ToInt32(ddlMonth);
                iday = Convert.ToInt32(ddlDay);
                DateTime DCurrent = new DateTime(year, iMnt, iday);

                DateTime after2week = DCurrent.AddDays(14);

                ViewBag.txt2Weeks = after2week.ToString("dd MMMM yyyy");

                DateTime after5week = DCurrent.AddDays(35);
                ViewBag.txt5To10 = after5week.ToString("dd MMMM yyyy");
                ViewBag.txtFiveWeeks = ViewBag.txt5To10;

                DateTime after10week = DCurrent.AddDays(70);
                ViewBag.txtFiveToTenWeeks = after10week.ToString("dd MMMM yyyy");
                ViewBag.txtTenWeeks = ViewBag.txtFiveToTenWeeks;

                DateTime after12week = DCurrent.AddDays(84);
                ViewBag.txt12Weeks = after12week.ToString("dd MMMM yyyy");

                DateTime after23week = DCurrent.AddDays(161);
                ViewBag.txt23Weeks = after23week.ToString("dd MMMM yyyy");

                DateTime after27week = DCurrent.AddDays(189);
                ViewBag.txt27Weeks = after27week.ToString("dd MMMM yyyy");

                DateTime after40week = DCurrent.AddDays(280);
                ViewBag.txt40Weeks = after40week.ToString("dd MMMM yyyy");
            }
            catch (Exception ex)
            {
                ViewBag.datt = "Please select option!!!";
            }
            list.Add(new
            {
                txt2Weeks = ViewBag.txt2Weeks,
                txt5To10 = ViewBag.txt5To10,
                txtFiveWeeks = ViewBag.txtFiveWeeks,
                txtFiveToTenWeeks = ViewBag.txtFiveToTenWeeks,
                txtTenWeeks = ViewBag.txtTenWeeks,
                txt12Weeks = ViewBag.txt12Weeks,
                txt23Weeks = ViewBag.txt23Weeks,
                txt27Weeks = ViewBag.txt27Weeks,
                txt40Weeks = ViewBag.txt40Weeks
            });
            return Json(list.SingleOrDefault(), JsonRequestBehavior.AllowGet);
        }

2020-09-01