Sunday, June 23, 2024

4 Decade Birthdays

On my milestone 40th birthday, I thought of sharing about how I celebrated my birthdays at different ages, Hope you enjoy reading the blog and relate or recollect few of your memories too. I would like to thank and appreciate all my family members and friends who were part of my birthday celebrations for the past 40 years at some point of my life. There is a saying "Life is a journey, Family members are like roads and friends are like trees". We need both in our life journey and play major role in our lives to make it more cheerful and colorful.

1. First Decade - Early Birthdays (1-10)

As many of you don't remember your first few birthdays, I'm no exception but based on what my parents told me, my first birthday was celebrated just between my parents. I don't think we have a pic of it, but below is my first pic of my life when I was about 6 months old. I was not able to sit properly, but my dad used his hand to support me in the background of the blanket.


Most of my first decade birthdays includes a standard routine of going to temple, going to school to share chocolates to classmates, visit a photo studio and eat out.

a. Photo Studio visit birthdays 

Camera was not in our hands those days, so we used to visit "Photo Studio" to get pictures on birthdays / Anniversaries. As a kid when I was in my primary school I wanted to share chocolates to my schoolmates, but don't want to attend the classes. Just share chocolates and leave after first session / class. Want to use the privilege of wearing new dress instead of regular school uniform on your birthday.

b. NTR dress Birthday

I remember my 1st standard birthday which was my 5th one. I had the NTR (Popular Movie Actor and Politician) style dress and was celebrated at my Uncle's (Mother's brother) place. This was my favorite dress for a very long time.

2. Second Decade - Pre-Teen/Teen Birthdays (11-20)

a. Battalion Birthday

As I grew older, I went to one of my friend's birthday in our apartment, and they had lot of invitees, seeing that I wanted to celebrate that way, but my parents was little hesitant for an obvious reason. But decided to do as they don't want to disappoint me. The guest list was big as we added few family members as well who are near by. Definitely it was a big gathering and the Battalion was about 50-60 people. I thoroughly enjoyed this birthday with many of my cousins and friends. The main reason I want to celebrated that way is to get more gifts from people.



b. Mangala Harathi Birthdays

In Hindu religion, there is a tradition of giving Mangala Harathi for well being of a person from the well wishers. So my mom used to do that for me on every birthday. Below are few of them.


c. Teenager Birthdays

I think I was around 13-14 years old and told my parents that I would be giving a party to my Childhood friends and that was the first time for me to go out all by ourself to a restaurant with any friend. After we (Gang of 6) completed our under graduation we all went to our first long trip to Tirupati. There are so many first things that we all did as a group. We all have so many memories to cherish with. Srikanth being the longest friend of my life since 2nd standard, followed by Kittu, Sai, Chandu and Ravikanth. We have been Friends who are in constant touch for a very long time. 

After I started my under graduation (BTech) , I got some new friends and started celebrated with them as well. But the celebration pattern of going to restaurants or bakery was same. I had great friends who always made me learn something new. I don't think I have pics for those birthdays so just adding some pics we had.


3. Third Decade - Young Adult Birthdays (21-30)

a. Scary Thrilling Birthday

About a week before my 22nd birthday my parents presented me a bike (Bajaj Pulsar) as a birthday gift. One of the best gift ever by my parents, also an expensive gift. 

I was very happy about it but there was something even more thrilling. On the night before my 22nd birthday, One of my under graduate friend Maheedhar came to my house around 10 pm. We were discussing some serious topic on the near by window around midnight, cool breeze was hitting us and we were enjoying the weather. Nowhere from outside the window, Suddenly I heard an external person voice shouting "Happy Birthday" as I was really shocked to see another friend Rakesh and I was so scared of it as it was so unexpected at midnight. It was scary because to reach my bedroom window he needs to climb our gate and wall. 

While all this was happening, my mom knock my bedroom door and said that my parents heard some noise outside and someone was trying to creep into the house. I was trying to explain my mom but I was surprised to see my dad have a stick in his hand to handle the assumed thief. It was hard for my parents to believe that crazy friends cross all the borders to celebrate birthday. Definitely one of my most memorable birthday ever. This was the debut of my mid-night birthday celebrations and I thoroughly enjoyed it. 


b. Mid night Birthdays

    For my 23rd and 24th birthdays I had a blast with my master's friends at Texas State University. We celebrated it during midnight and they are wild and bold. There was too many birthday bumps to handle, I couldn't walk properly for the next couple of days, but i had great friends.


I met few more friends at my work place and my 25th birthday was also celebrated at midnight and I got addicted to midnight birthday celebrations. 

c. Realization Birthdays

I moved to a new small place in Kentucky. The saga of mid-night birthday celebrations continued for the straight 4 years, thought life would be same, but on my 26th birthday, I was waiting for some one to visit or celebrate but no one did and not even a call at mid night. I got a call from 1 or 2 close friends and my parents in the morning though. I was really not happy that I'm not getting any calls and no one is wishing me. Then realized that Facebook had some setting changes and it was not notifying my birthday. After I fixed that setting, I got couple of calls and few of my friends visited my place and had good time. Facebook was a savior, at least because of it people wish each other. Thanks to Kapil, Shubham, Nishtha, Abhishek, and Jessica for making this day. This birthday was something special because I felt like I was sitting in a Round Table Conference in a Global Summit Meeting as I had 2 American, 1 Russian and bunch of Indian friends. Thanks for all of them who made it possible.


With the kind of transition I had from Midnight birthdays to No midnight birthday wishes I didn't expect anything from my 27th birthday and realization started that everyone will be busy in their own life and I'm one in millions of people in the world. But I wanted to make it something special for my parents who were always supportive in my lows and highs. So gave them the best gift on my birthday by telling them that "I'm ready to get married". So they asked me for a nice picture and I did the best photoshoot of my life to find my wife. Definitely a deceiving picture which worked.. LOL!!! 


d. Family birthdays

I celebrated my 28th birthday with my wife. I was fortunate enough to have her in my life and she definitely made my birthday special.



On my 29th birthday, After a long time I celebrated my birthday with my Father and we had new addition to our family Aarush (my elder son). 


4. Fourth Decade Birthdays (31-40)

a. Family birthdays
I've been celebrating most of my birthdays with my family members with routine of going to temple, cutting a cake, going out for lunch / dinner. Celebrations has been fun with my 2 sons and their crazy activities. Life has been pretty busy with family, let me share something interesting and not related to my birthday. It was in 2021 and we were married for about 8 years, One day kids were getting ready to go to school and I noticed my wife wore a new dress and asked her if there is any special event at her office, she said no. I dropped her at Metro station on bike and came back home. I opened my phone and Facebook was a Savior once again, it reminded me that its my Wife's birthday. I called her to wish and bought a small gift to her, it might be hard to believe but it was the second time I gifted something on her birthday after our wedding. Her response was "Why are you trying new things in life". I feel incredibly lucky to have such an understanding wife.


b. 40th Milestone birthday
Since I've been celebrating with my family for over a decade, on the 40th milestone birthday I wanted to celebrate with my best childhood friends and their families. We had most of them covered and spent quality time together which was due for a very long time. One of my friend said "We are all 18 at Heart" and we all had gala time.



I might have missed mentioning few more of my friends / family members as I can't fit all of you guys here. Don't feel bad if I didn't mention your name. You guys are in my ❤ and memories of my life. 

I hope you all enjoyed reading about my birthday celebrations. Thanks for taking out time to read it !!!

Wednesday, August 10, 2022

Mom's Memories







On the 10th Death Anniversary of my mother Nirmala, I would like to write a blog to share some important phases / memories / events of her life. It has been a long time since I wrote a blog but will try to keep it interesting. 

1. Privileged Childhood 
Childhood Pic

Being the youngest girl child of 8 siblings, she was always treated as a child through out her life, her nick name was Chinna Ammayi (Little Girl). She could only managed to get to 7th standard, but she was able to read/write/speak Telugu fluently, and some broken Hindi as well.

She may not have born with silver spoon but was one of the few Privileged people in India, who travelled in flight, "Flying in air" was a rare stuff at that point of time. Irony is that me or my dad could never get her on to flight again.
Childhood Trip

2. Wedding Transition 

    a. On April 8th 1982, she had an important day of her life , and she got married to my father.


Wedding Pic
    
    b. My father had always been great support to her in all the situations.
    
    c. Life was not so easy for her to handle for the first few years of post wedding, managing family with a minimum financial resources was a challenging task.
    
    d. She shared so many instances of this not so good phase of life, but she made heart hard to handle them.
    
    e. There were section of people who didn't treat her well, which she carried that pain through out her life and it impacted her health.
    
    f. Transition from "Flying in air" before wedding to "Making heart hard" was a tough situation but god gave her the strength to go pass through it.

3. Family

    a. Immediate Family

        i. Happy Husband: 

One of the first trip of our family


            She was lucky to have a happy husband. They both coordinately took all the decisions in their life with minimum conflict of interests. My dad was busy at work at times and couldn't spend much time with us but she always understood him. They always celebrated the important events of life like Anniversaries / our birthdays by visiting temples / Restaurants. But they believed together that Son's education was their first priority of all.

            Few of the happiest moments in life:  
            a. My Dad being a Civil Engineer by himself, they were very determined to build their own Dream house.
            b. When we got first 4 Wheeler Maruti 800 car which is mostly first car of most of the Indians of their generation :) !!

During Construction of our First House


House Warming Ceremony

            She always prepared home cooked food, no matter what time my dad starts from home. My dad always fulfilled her wishes to visit many holy places like Kasi, Rameswaram, Puri, Tirupati... many other places and had good times over their 3 decades of togetherness.      



ii. Only Child: 

            She being one of the 8 siblings and my dad being one of the 8 siblings as well, my parents decided to have only One child, so that I don't have sibling competition...LOL !!

@ Kanyakumari, TamilNadu




            The only person anyone could ever ask you a question "You had your meal?" even before they ask "How are you?" is your mother. No matter what time of the day I call her, she asks the same first question.
            
@ Puri, Orissa
            
            She had been Diabetic since she was in early 30's and medicines at that time was not that great but she took care of her diet and controlled her self eating sweats / desserts. She managed well around 2 decades.

            Being the only child all my mom's attention was on me, I never wanted to leave my happy home and work at some other place, but there was a point where she asked if I would go to abroad for further studies and I accepted it before she could change her mind. 

            Most of the times my mom was very emotional and sensitive. But I also saw contrast shade of her, when ever situations were not going as expected, she never looked depressed, she always believed that things will get better and will be out the those bad phases soon. She has always been a great support to me.

Visited many places but found the best one.

    b. Sibling's Family members:

         She loves her brothers and elder sister a lot, she had great support from them through out her life. There were few instances where my dad got sick couple of times around 2 or 3 AM. First thing she did is to call her brothers, and they rushed to our home for help immediately to take to hospital. 

        
Mom with her siblings, nephew and nieces 
       
         I still remember her brothers having tea at my home and chat for long hours of time. I believe this is something rare these days as we all are busy with cell phones and life style.
        
        She had a very healthy relationship with her sibling's family members, all of them were very caring and took care of her a lot with their support. Some of my aunts and cousins never missed wishing on her birthday or anniversary. She was fortunate to have such a lovely family members.      
        
        These were just couple of the instances, and I may have to write a separate blog to tell about her relationship with her siblings and their families😊.

    

     c. Husband's Family members:

            My mom did her best to be the responsible eldest daughter in law. As my dad had 8 siblings, we have quite a big sweet cousins as well. 

            Being one of the youngest of all the siblings, she didn't had any younger sisters, but god had other plans for her. She had the best co-sisters (who are all younger to her) one can ever ask. They always have been very supportive and friendly with her in all aspects😊

My Dad's Brothers and family

4. Favorite Times

@Konark Temple

@Srisailam Temple


    a. Visiting Holy places - Most of the places we visited in our life were holy places. She never miss any opportunity to visit even a small temple.

    b. Playing chess / games - People say, you need to be smart to play chess 😎. She was very good at playing chess, I almost lost about 10's of games before I could win over her for the first time. She was my first and only chess guru. We also played many other games like Business (similar to Monopoly), Asta chamma..etc especially in the hot summer holidays to keep me engaged inside the home. 

    c. Cooking - I always enjoyed my mom's dishes, Aloo (Potato) and Bendi (Okra) fry are the best. Summer Mango pickles are the specials, her Daughter In-Law (my wife) still uses the same recipe for Mango pickle to prepare. Gulab jamun is the most made desert. 

    d. Talking to closed ones - Talking to people was one of her favorite things to do. She got along well with most of the people.

    e. Golden heart: Even though she didn't buy much gold as she expected, my Dad used to watch all kind of news in ETV channel for 1/2 hour, I was interested in sports update but my mom used to wait only for the gold rate for the day.

    f. Reading Rapidex to learn English (Telugu to English Translator) - She tried all her life to learn English but was partially successful with it.

    g. Watching Old movies - Akkineni Nageshwar Rao was her favorite actor and Kamal Hasan's "Akali Rajyam" (Hunger Country) was her all time favorite movie, and she never missed watching the movie on TV again and again. 

    h. Picture time: She just love being in pictures, we had a Negative Film Camera way long back in  1990's. It was not a common household thing at that time.


5. Perfect Wedding Date

Wedding time

    a. Sometimes I used to think my mom was too old fashioned, yes she is but her thinking was way ahead in some contexts, she regrets not being a working women, one of the advice she gave to my wife was to be a "Working Woman". 

    b. My mother was like every typical Indian mother who wants to choose a girl of her choice and I know she would get the best girl. So left her the choice 😄!!

    c. My parents got married on April 8th 1982, and we never knew that exactly after 30 years on the same day, I would be married on April 8th 2012 making it a Perfect Wedding Date. She had the best phase of her life and never saw her being so happy.

6. Final Destination

        She had a long due of going to one of most important trip of her life, Char Dham Yatra. She was just waiting for my wedding to finish and soon she left to visit these famous temples. After she returned from trip, Golden heart stopped beating, she passed away with heart attack and left vacuum (which can't be filled) in our lives on August 11th 2012 at the age of around 50

No matter how good or bad your childhood is, your parents tried their best to give you a better life. Take care of them when they need you. 

Hope you enjoyed knowing about my mother. Thanks for taking time to read it.



Tuesday, November 27, 2018

MVC basic details

http://www.binaryintellect.net/articles/4a00a9ce-73e5-4d89-aaae-2d835eca0854.aspx


Models:

 public class Customer
    {
        [EdmScalarPropertyAttribute(EntityKeyProperty = true, IsNullable = false)]
        public int CustomerID { get; set; }
        public string CustomerName { get; set; }
        public string CustomerContact { get; set; }
    }

 public class CustomersViewModel
    {
        public List Customers { get; set; }
        public Customer SelectedCustomer { get; set; }
        public string DisplayMode { get; set; }
    }

Controllers:

namespace DisplayAllInOnePage.Controllers
{
    public class CustomersController : Controller
    {
        private ApplicationDbContext db = new ApplicationDbContext();

        // GET: Customers
        public ActionResult Index()
        {
            //List customerList = new List();
            //Customer customer1 = new Customer();
            //customer1.CustomerID = 1;
            //customer1.CustomerName = "Name1";
            //customer1.CustomerContact = "Contact1";

            //Customer customer2 = new Customer();
            //customer2.CustomerID = 2;
            //customer2.CustomerName = "Name2";
            //customer2.CustomerContact = "Contact2";

            //var all = from c in db.Customers select c;
            //db.Customers.RemoveRange(all);
            //db.SaveChanges();

            //db.Customers.Add(customer1);
            //db.Customers.Add(customer2);
            //db.SaveChanges();

            CustomersViewModel model = new CustomersViewModel();
            model.Customers = db.Customers.OrderBy(m => m.CustomerID).Take(5).ToList();
            model.SelectedCustomer = null;
            return View(model);

            //return View(db.Customers.ToList());
        }
       
        [HttpPost]
        public ActionResult New()
        {           
            CustomersViewModel model = new CustomersViewModel();
            model.Customers = db.Customers.OrderBy(
                            m => m.CustomerID).Take(5).ToList();
            model.SelectedCustomer = null;
            model.DisplayMode = "WriteOnly";
            return View("Index", model);           
        }

        [HttpPost]
        public ActionResult Insert(Customer obj)
        {
            db.Customers.Add(obj);
            db.SaveChanges();

            CustomersViewModel model = new CustomersViewModel();
            model.Customers = db.Customers.OrderBy(
                                m => m.CustomerID).Take(5).ToList();
            model.SelectedCustomer = db.Customers.Find(obj.CustomerID);
            model.DisplayMode = "ReadOnly";
            return View("Index", model);           
        }

        [HttpPost]
        public ActionResult Select(int id)
        {
            CustomersViewModel model = new CustomersViewModel();
            model.Customers = db.Customers.OrderBy(
                        m => m.CustomerID).Take(5).ToList();
            model.SelectedCustomer = db.Customers.Find(id);
            model.DisplayMode = "ReadOnly";
            return View("Index", model);
        }

        [HttpPost]
        public ActionResult Edit(int id)
        {
            CustomersViewModel model = new CustomersViewModel();
            model.Customers = db.Customers.OrderBy(
                            m => m.CustomerID).Take(5).ToList();
            model.SelectedCustomer = db.Customers.Find(id);
            model.DisplayMode = "ReadWrite";
            return View("Index", model);           
        }

        [HttpPost]
        public ActionResult Update(Customer obj)
        {
            Customer existing = db.Customers.Find(obj.CustomerID);
            existing.CustomerName = obj.CustomerName;
            existing.CustomerContact = obj.CustomerContact;
            db.SaveChanges();

            CustomersViewModel model = new CustomersViewModel();
            model.Customers = db.Customers.OrderBy(
                            m => m.CustomerID).Take(5).ToList();

            model.SelectedCustomer = existing;
            model.DisplayMode = "ReadOnly";
            return View("Index", model);           
        }

        [HttpPost]
        public ActionResult Delete(int id)
        {           
            Customer existing = db.Customers.Find(id);
            db.Customers.Remove(existing);
            db.SaveChanges();

            CustomersViewModel model = new CustomersViewModel();
            model.Customers = db.Customers.OrderBy(
                                m => m.CustomerID).Take(5).ToList();

            model.SelectedCustomer = null;
            model.DisplayMode = "";
            return View("Index", model);           
        }

        [HttpPost]
        public ActionResult Cancel(int id)
        {
            CustomersViewModel model = new CustomersViewModel();
            model.Customers = db.Customers.OrderBy(
                                m => m.CustomerID).Take(5).ToList();
            model.SelectedCustomer = db.Customers.Find(id);
            model.DisplayMode = "ReadOnly";
            return View("Index", model);           
        }

        //// GET: Customers/Details/5
        //public ActionResult Details(int? id)
        //{
        //    if (id == null)
        //    {
        //        return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
        //    }
        //    Customer customer = db.Customers.Find(id);
        //    if (customer == null)
        //    {
        //        return HttpNotFound();
        //    }
        //    return View(customer);
        //}

        //// GET: Customers/Create
        //public ActionResult Create()
        //{       
        //    return View();
        //}

        //// POST: Customers/Create
        //// To protect from overposting attacks, please enable the specific properties you want to bind to, for
        //// more details see http://go.microsoft.com/fwlink/?LinkId=317598.
        //[HttpPost]
        //[ValidateAntiForgeryToken]
        //public ActionResult Create([Bind(Include = "CustomerID,CustomerName,CustomerContact")] Customer customer)
        //{
        //    if (ModelState.IsValid)
        //    {
        //        db.Customers.Add(customer);
        //        db.SaveChanges();
        //        return RedirectToAction("Index");
        //    }

        //    return View(customer);
        //}

        //// GET: Customers/Edit/5
        //public ActionResult Edit(int? id)
        //{
        //    if (id == null)
        //    {
        //        return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
        //    }
        //    Customer customer = db.Customers.Find(id);
        //    if (customer == null)
        //    {
        //        return HttpNotFound();
        //    }
        //    return View(customer);
        //}

        //// POST: Customers/Edit/5
        //// To protect from overposting attacks, please enable the specific properties you want to bind to, for
        //// more details see http://go.microsoft.com/fwlink/?LinkId=317598.
        //[HttpPost]
        //[ValidateAntiForgeryToken]
        //public ActionResult Edit([Bind(Include = "CustomerID,CustomerName,CustomerContact")] Customer customer)
        //{
        //    if (ModelState.IsValid)
        //    {
        //        db.Entry(customer).State = EntityState.Modified;
        //        db.SaveChanges();
        //        return RedirectToAction("Index");
        //    }
        //    return View(customer);
        //}

        //// GET: Customers/Delete/5
        //public ActionResult Delete(int? id)
        //{
        //    if (id == null)
        //    {
        //        return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
        //    }
        //    Customer customer = db.Customers.Find(id);
        //    if (customer == null)
        //    {
        //        return HttpNotFound();
        //    }
        //    return View(customer);
        //}

        //// POST: Customers/Delete/5
        //[HttpPost, ActionName("Delete")]
        //[ValidateAntiForgeryToken]
        //public ActionResult DeleteConfirmed(int id)
        //{
        //    Customer customer = db.Customers.Find(id);
        //    db.Customers.Remove(customer);
        //    db.SaveChanges();
        //    return RedirectToAction("Index");
        //}

        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                db.Dispose();
            }
            base.Dispose(disposing);
        }
    }
}


Views:

Index.cshtml


@model DisplayAllInOnePage.Models.CustomersViewModel

@{
    Layout = null;
}





   
    Index
   

   

List of Customers



   

                       value="Insert" formaction="/Customers/new" />
       

       

           
                CustomerID
                CompanyName
                Actions
           
            @foreach (var item in Model.Customers)
            {
                if (Model.SelectedCustomer != null)
                {
                    if (item.CustomerID == Model.SelectedCustomer.CustomerID)
                    {
                        @:
                    }
                    else
                    {
                        @:
                    }
                }
                else
                {
                    @:
                }
                @item.CustomerID
                @item.CustomerName
               
                                               formaction="/Customers/select/@item.CustomerID"
                           value="Select" />
               
                   
                                                       formaction="/Customers/delete/@item.CustomerID"
                               value="Delete" />
                   
                    @:
            }
       
   
   

    @{
        if (Model.SelectedCustomer != null)
        {
            if (Model.DisplayMode == "ReadOnly")
            {
                Html.RenderPartial
                ("ShowCustomer", Model.SelectedCustomer);
            }
            if (Model.DisplayMode == "ReadWrite")
            {
                Html.RenderPartial
                ("EditCustomer", Model.SelectedCustomer);
            }
        }
        if (Model.DisplayMode == "WriteOnly")
        {
            Html.RenderPartial("InsertCustomer",
            new DisplayAllInOnePage.Models.Customer());
        }
    }
   






Create.cshtml

@model DisplayAllInOnePage.Models.Customer

@{
    ViewBag.Title = "Create";
}

Create




@using (Html.BeginForm())
{
    @Html.AntiForgeryToken()
   
   

       

Customer


       

        @Html.ValidationSummary(true, "", new { @class = "text-danger" })
       

            @Html.LabelFor(model => model.CustomerName, htmlAttributes: new { @class = "control-label col-md-2" })
           

                @Html.EditorFor(model => model.CustomerName, new { htmlAttributes = new { @class = "form-control" } })
                @Html.ValidationMessageFor(model => model.CustomerName, "", new { @class = "text-danger" })
           
       

       

            @Html.LabelFor(model => model.CustomerContact, htmlAttributes: new { @class = "control-label col-md-2" })
           

                @Html.EditorFor(model => model.CustomerContact, new { htmlAttributes = new { @class = "form-control" } })
                @Html.ValidationMessageFor(model => model.CustomerContact, "", new { @class = "text-danger" })
           
       

       

           

               
           
       
   
}


    @Html.ActionLink("Back to List", "Index")


@section Scripts {
    @Scripts.Render("~/bundles/jqueryval")
}


Delete.cshtml

@model DisplayAllInOnePage.Models.Customer

@{
    ViewBag.Title = "Delete";
}

Delete


Are you sure you want to delete this?

   

Customer

   
   
       
            @Html.DisplayNameFor(model => model.CustomerName)
       

       
            @Html.DisplayFor(model => model.CustomerName)
       

       
            @Html.DisplayNameFor(model => model.CustomerContact)
       

       
            @Html.DisplayFor(model => model.CustomerContact)
       

   

    @using (Html.BeginForm()) {
        @Html.AntiForgeryToken()

       
            |
            @Html.ActionLink("Back to List", "Index")
       
    }


Details.cshtml

@model DisplayAllInOnePage.Models.Customer

@{
    ViewBag.Title = "Details";
}

Details


   

Customer

   
   
       
            @Html.DisplayNameFor(model => model.CustomerName)
       

       
            @Html.DisplayFor(model => model.CustomerName)
       

       
            @Html.DisplayNameFor(model => model.CustomerContact)
       

       
            @Html.DisplayFor(model => model.CustomerContact)
       

   
    @Html.ActionLink("Edit", "Edit", new { id = Model.CustomerID }) |
    @Html.ActionLink("Back to List", "Index")


Edit.cshtml

@model DisplayAllInOnePage.Models.Customer

@{
    ViewBag.Title = "Edit";
}

Edit



@using (Html.BeginForm())
{
    @Html.AntiForgeryToken()
    
   
       

Customer

       
        @Html.ValidationSummary(true, "", new { @class = "text-danger" })
        @Html.HiddenFor(model => model.CustomerID)

       
            @Html.LabelFor(model => model.CustomerName, htmlAttributes: new { @class = "control-label col-md-2" })
           
                @Html.EditorFor(model => model.CustomerName, new { htmlAttributes = new { @class = "form-control" } })
                @Html.ValidationMessageFor(model => model.CustomerName, "", new { @class = "text-danger" })
           
       

       
            @Html.LabelFor(model => model.CustomerContact, htmlAttributes: new { @class = "control-label col-md-2" })
           
                @Html.EditorFor(model => model.CustomerContact, new { htmlAttributes = new { @class = "form-control" } })
                @Html.ValidationMessageFor(model => model.CustomerContact, "", new { @class = "text-danger" })
           
       

       
           
               
           
       
   
}

    @Html.ActionLink("Back to List", "Index")

@section Scripts {
    @Scripts.Render("~/bundles/jqueryval")
}


EditCustomer.cshtml

@model DisplayAllInOnePage.Models.Customer

@using (Html.BeginForm("Update", "Home", FormMethod.Post))
{
   
       
            Customer ID :
           
                @Html.TextBoxFor(m => m.CustomerID,
                         new { @readonly = "readonly" })
       
   
   
        Company Name :
        @Html.TextBoxFor(m => m.CustomerName)
   
   
        Contact Name :
        @Html.TextBoxFor(m => m.CustomerContact)
   
    
   
       
           
                   formaction="/Customers/update" />
           
                   formaction="/Customers/cancel/@Model.CustomerID" />
       
   
}



InsertCustomer.cshtml

@model DisplayAllInOnePage.Models.Customer

@using (Html.BeginForm("Insert", "Home", FormMethod.Post))
{
   
       
            Customer ID :
            @Html.TextBoxFor(m => m.CustomerID)
       
       
            Customer Name :
            @Html.TextBoxFor(m => m.CustomerName)
       
       
            Contact Name :
            @Html.TextBoxFor(m => m.CustomerContact)
       
        
       
           
               
                       formaction="/Customers/insert" />
               
                       formaction="/Customers/index" />
           
       
   
}

ShowCustomer.cshtml

@model DisplayAllInOnePage.Models.Customer

@using (Html.BeginForm("Edit", "Home", FormMethod.Post))
{
   
       
            Customer ID :
            @Model.CustomerID
       
       
            Customer Name :
            @Model.CustomerName
       
       
            Contact Name :
            @Model.CustomerContact
       
        
       
           
               
                       formaction="/Customers/edit/@Model.CustomerID" />
               
                       formaction="/Customers/index" />
           
       
   
}








Sunday, November 25, 2018

MVC Web API Sample

Referred Link with some changes.

https://www.c-sharpcorner.com/article/crud-Asp-Net-web-api-with-entity-framework-in-Asp-Net-mvc/

1. Create new Project and select Web API Project.
2. Create the EF ADO.NET Entity model
3. Build the project
4. Create Web API controllers for all tables.
5. Check if all APIs are working fine like below:
http://localhost:62279/api/Categories
http://localhost:62279/api/ListItems
6. Now add a new MVC project with name ending with Presentation to the solution.
7. Add Models for all the tables just copy from edmx file or use following template.
using System;
using System.ComponentModel.DataAnnotations;

namespace MVCPersatantion.Models
{
public class Customer
{
[Display(Name = "CustomerId")]
public int CustomerId { get; set; }
[Display(Name = "Name")]
public string Name { get; set; }
[Display(Name = "Address")]
public string Address { get; set; }
[Display(Name = "MobileNo")]
public string MobileNo { get; set; }
[Display(Name = "Birthdate")]
[DataType(DataType.Date)]
public DateTime Birthdate { get; set; }
[Display(Name = "EmailId")]
public string EmailId { get; set; }

}

}
8. Create ViewModel folder and add ViewModel files.
9. Add all ViewModel files like CategoryViewModel
10. Add the following code, add the missing dll if it is as follows.

Add a reference to System.Net.Http.Formatting.dll. This assembly is also available in the C:\Program Files\Microsoft ASP.NET\ASP.NET MVC 4\Assemblies folder.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Web;

namespace MVCOutOfBasketClient.Models
{
    public class CategoryClient
    {
        private string Base_URL = "http://localhost:62279/api/";

        public IEnumerable findAll()
        {
            try
            {
                HttpClient client = new HttpClient();
                client.BaseAddress = new Uri(Base_URL);
                client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
                HttpResponseMessage response = client.GetAsync("Categories").Result;

                if (response.IsSuccessStatusCode)
                    return response.Content.ReadAsAsync>().Result;
                return null;
            }
            catch
            {
                return null;
            }
        }
        public Category find(int id)
        {
            try
            {
                HttpClient client = new HttpClient();
                client.BaseAddress = new Uri(Base_URL);
                client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
                HttpResponseMessage response = client.GetAsync("Categories/" + id).Result;

                if (response.IsSuccessStatusCode)
                    return response.Content.ReadAsAsync().Result;
                return null;
            }
            catch
            {
                return null;
            }
        }
        public bool Create(Category Category)
        {
            try
            {
                HttpClient client = new HttpClient();
                client.BaseAddress = new Uri(Base_URL);
                client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
                HttpResponseMessage response = client.PostAsJsonAsync("Categories", Category).Result;
                return response.IsSuccessStatusCode;
            }
            catch
            {
                return false;
            }
        }
        public bool Edit(Category Category)
        {
            try
            {
                HttpClient client = new HttpClient();
                client.BaseAddress = new Uri(Base_URL);
                client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
                HttpResponseMessage response = client.PutAsJsonAsync("Categories/" + Category.CustomerId, Category).Result;
                return response.IsSuccessStatusCode;
            }
            catch
            {
                return false;
            }
        }
        public bool Delete(int id)
        {
            try
            {
                HttpClient client = new HttpClient();
                client.BaseAddress = new Uri(Base_URL);
                client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
                HttpResponseMessage response = client.DeleteAsync("Categories/" + id).Result;
                return response.IsSuccessStatusCode;
            }
            catch
            {
                return false;
            }
        }
    }
}


11. Add MVC Controllers

We have to add a controller, so for this right click on Controllers folder and add a controller and give the name for ex.Customer and write the code and call the service client method.



using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Entity;
using System.Linq;
using System.Net;
using System.Web;
using System.Web.Mvc;
using MVCOutOfBasketClient.Models;

namespace MVCOutOfBasketClient.Controllers
{
    public class QuantityUnitsController : Controller
    {
        // GET: QuantityUnits
        public ActionResult Index()
        {
            QuantityUnitClient quantityUnitClient = new QuantityUnitClient();
            List listQuantityUnit = new List();
            listQuantityUnit = (List) quantityUnitClient.findAll();
         
            return View(listQuantityUnit);
        }

        // GET: QuantityUnits/Details/5
        public ActionResult Details(int? id)
        {
            if (id == null)
            {
                return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
            }

            QuantityUnitClient quantityUnitClient = new QuantityUnitClient();
            QuantityUnit quantityUnit = new QuantityUnit();
            quantityUnit = (QuantityUnit)quantityUnitClient.find((int)id);

            if (quantityUnit == null)
            {
                return HttpNotFound();
            }
            return View(quantityUnit);
        }

        // GET: QuantityUnits/Create
        public ActionResult Create()
        {
            return View();
        }

        // POST: QuantityUnits/Create
        // To protect from overposting attacks, please enable the specific properties you want to bind to, for
        // more details see http://go.microsoft.com/fwlink/?LinkId=317598.
        [HttpPost]
        [ValidateAntiForgeryToken]
        public ActionResult Create([Bind(Include = "QuantityUnitId,QuantityUnitName,QuantityUnitDescription")] QuantityUnit quantityUnit)
        {
            if (ModelState.IsValid)
            {
                QuantityUnitClient quantityUnitClient = new QuantityUnitClient();
                quantityUnitClient.Create(quantityUnit);
                return RedirectToAction("Index");
            }

            return View(quantityUnit);
        }

        // GET: QuantityUnits/Edit/5
        public ActionResult Edit(int? id)
        {
            if (id == null)
            {
                return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
            }

            QuantityUnitClient quantityUnitClient = new QuantityUnitClient();
            QuantityUnit quantityUnit = quantityUnitClient.find((int)id);

            if (quantityUnit == null)
            {
                return HttpNotFound();
            }
            return View(quantityUnit);
        }

        // POST: QuantityUnits/Edit/5
        // To protect from overposting attacks, please enable the specific properties you want to bind to, for
        // more details see http://go.microsoft.com/fwlink/?LinkId=317598.
        [HttpPost]
        [ValidateAntiForgeryToken]
        public ActionResult Edit([Bind(Include = "QuantityUnitId,QuantityUnitName,QuantityUnitDescription")] QuantityUnit quantityUnit)
        {
            if (ModelState.IsValid)
            {
                QuantityUnitClient quantityUnitClient = new QuantityUnitClient();
                quantityUnitClient.Edit(quantityUnit);             

                return RedirectToAction("Index");
            }
            return View(quantityUnit);
        }

        // GET: QuantityUnits/Delete/5
        public ActionResult Delete(int? id)
        {
            if (id == null)
            {
                return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
            }

            QuantityUnitClient quantityUnitClient = new QuantityUnitClient();
            QuantityUnit quantityUnit = quantityUnitClient.find((int)id);

            if (quantityUnit == null)
            {
                return HttpNotFound();
            }
            return View(quantityUnit);
        }

        // POST: QuantityUnits/Delete/5
        [HttpPost, ActionName("Delete")]
        [ValidateAntiForgeryToken]
        public ActionResult DeleteConfirmed(int id)
        {
            QuantityUnitClient quantityUnitClient = new QuantityUnitClient();
            QuantityUnit quantityUnit = null;
            quantityUnit = quantityUnitClient.find((int)id);
            if (quantityUnit != null)
            {
                quantityUnitClient.Delete((int)id);
            }
            else
            {
                return HttpNotFound();
            }
            return RedirectToAction("Index");
        }
    }
}