Esempio n. 1
0
        private void getGuestMeals(string mid)
        {
            string                 response = "";
            GuestMealsModel        gmm      = new GuestMealsModel();
            List <GuestMealsModel> gmList   = new List <GuestMealsModel>();

            //Get all guest meals
            gmm.memberId = mid;
            gmm.date     = getDate();
            foreach (GuestMealsModel gm in gmm.getAllGuestMealByMemberIdAndDate())
            {
                gmList.Add(gm);
            }

            //Process result
            if (gmm.response == "500")
            {
                response           = "e";
                ViewBag.GuestTotal = 0;
            }
            else
            {
                response = "s";
                //Count meals
                int countB = 0;
                int countL = 0;
                int countD = 0;
                foreach (GuestMealsModel g in gmList)
                {
                    if (g.breakfast == "1")
                    {
                        countB++;
                    }

                    if (g.lunch == "1")
                    {
                        countL++;
                    }

                    if (g.dinner == "1")
                    {
                        countD++;
                    }
                }
                ViewBag.GuestB     = countB;
                ViewBag.GuestL     = countL;
                ViewBag.GuestD     = countD;
                ViewBag.GuestTotal = countB + countL + countD;
            }
            ViewBag.GuestResponse = response;
        }
Esempio n. 2
0
        private void processMealData()
        {
            //Get all member
            string            response = "";
            UsersModel        usm      = new UsersModel();
            List <UsersModel> usList   = new List <UsersModel>();

            foreach (UsersModel user in usm.getAllUsers())
            {
                usList.Add(user);
            }
            if (usm.response == "500")
            {
                response = "e";
            }
            else
            {
                response = "s";
                int    breakfastT = 0;
                int    lunchT     = 0;
                int    dinnerT    = 0;
                int    breakfastM = 0;
                int    lunchM     = 0;
                int    dinnerM    = 0;
                int    breakfastG = 0;
                int    lunchG     = 0;
                int    dinnerG    = 0;
                string membersB   = "";
                string membersL   = "";
                string membersD   = "";
                foreach (UsersModel u in usList)
                {
                    //Collect daily meals
                    SelfMealsModel  smm = new SelfMealsModel();
                    GuestMealsModel gmm = new GuestMealsModel();
                    smm.memberId = u.id;
                    gmm.memberId = u.id;
                    smm.date     = getDate();
                    gmm.date     = getDate();

                    //List all meals by member
                    List <SelfMealsModel>  smList = new List <SelfMealsModel>();
                    List <GuestMealsModel> gmList = new List <GuestMealsModel>();
                    foreach (SelfMealsModel sm in smm.getAllMealByMemberIdAndDate())
                    {
                        smList.Add(sm);
                    }
                    foreach (GuestMealsModel gm in gmm.getAllGuestMealByMemberIdAndDate())
                    {
                        gmList.Add(gm);
                    }

                    //Get all self meals
                    int sb = 0;
                    int sl = 0;
                    int sd = 0;

                    foreach (SelfMealsModel s in smList)
                    {
                        if (s.breakfast == "1")
                        {
                            sb++;
                        }
                        if (s.lunch == "1")
                        {
                            sl++;
                        }
                        if (s.dinner == "1")
                        {
                            sd++;
                        }
                    }

                    if (sb > 0)
                    {
                        membersB = membersB + "<btn id='b_" + u.id + "' class='btn btn-danger' value='" + Url.Action("cancelBreakfast", new { m = u.id }) + "' name='" + u.fullname + "' onclick='confirmRemovingB(" + u.id + ")'>" + u.fullname + "</btn> ";
                    }
                    if (sl > 0)
                    {
                        membersL = membersL + "<btn id='l_" + u.id + "' class='btn btn-danger' value='" + Url.Action("cancelLunch", new { m = u.id }) + "' name='" + u.fullname + "' onclick='confirmRemovingL(" + u.id + ")'>" + u.fullname + "</btn> ";
                    }
                    if (sd > 0)
                    {
                        membersD = membersD + "<btn id='d_" + u.id + "' class='btn btn-danger' value='" + Url.Action("cancelDinner", new { m = u.id }) + "' name='" + u.fullname + "' onclick='confirmRemovingD(" + u.id + ")'>" + u.fullname + "</btn> ";
                    }

                    breakfastM = breakfastM + sb;
                    lunchM     = lunchM + sl;
                    dinnerM    = dinnerM + sd;

                    //Get all guest meals
                    int gb = 0;
                    int gl = 0;
                    int gd = 0;

                    foreach (GuestMealsModel g in gmList)
                    {
                        if (g.breakfast == "1")
                        {
                            gb++;
                        }
                        if (g.lunch == "1")
                        {
                            gl++;
                        }
                        if (g.dinner == "1")
                        {
                            gd++;
                        }
                    }

                    breakfastG = breakfastG + gb;
                    lunchG     = lunchG + gl;
                    dinnerG    = dinnerG + gd;
                }

                breakfastT = breakfastM + breakfastG;
                lunchT     = lunchM + lunchG;
                dinnerT    = dinnerM + dinnerG;

                //Process all data
                ViewBag.Bt = breakfastT;
                ViewBag.Lt = lunchT;
                ViewBag.Dt = dinnerT;

                ViewBag.Bm = breakfastM;
                ViewBag.Lm = lunchM;
                ViewBag.Dm = dinnerM;

                ViewBag.Bg = breakfastG;
                ViewBag.Lg = lunchG;
                ViewBag.Dg = dinnerG;

                ViewBag.mB = membersB;
                ViewBag.mL = membersL;
                ViewBag.mD = membersD;
            }
            ViewBag.HomeResponse = response;
        }
Esempio n. 3
0
        private void processGuestDetails()
        {
            string                 response = "";
            string                 msg      = "";
            GuestMealsModel        gmm      = new GuestMealsModel();
            List <GuestMealsModel> gmList   = new List <GuestMealsModel>();

            //Get all guest meals
            UserSessionModel usm = (UserSessionModel)Session["user"];

            gmm.memberId = usm.userid;
            gmm.date     = getDate();
            foreach (GuestMealsModel gm in gmm.getAllGuestMealByMemberIdAndDate())
            {
                gmList.Add(gm);
            }

            //Process result
            if (gmm.response == "500")
            {
                response = "e";
                msg      = "<h3>Something went wrong! Try again...</h3>";
            }
            else
            {
                response = "s";
                msg      = msg + "<table class='table table-bordered'>"
                           + "<tr>"
                           + "<td><b>#</b></td>"
                           + "<td><b>Breakfast</b></td>"
                           + "<td><b>Lunch</b></td>"
                           + "<td><b>Dinner</b></td>"
                           + "<td><b>Options</b></td>"
                           + "</tr>";

                int count = 1;
                foreach (GuestMealsModel gm in gmList)
                {
                    msg = msg + "<tr><td>" + count + "</td>";
                    if (gm.breakfast == "1")
                    {
                        msg = msg + "<td><p class='text-success'>Y</p></td>";
                    }
                    else
                    {
                        msg = msg + "<td><p class='text-danger'>N</p></td>";
                    }

                    if (gm.lunch == "1")
                    {
                        msg = msg + "<td><p class='text-success'>Y</p></td>";
                    }
                    else
                    {
                        msg = msg + "<td><p class='text-danger'>N</p></td>";
                    }

                    if (gm.dinner == "1")
                    {
                        msg = msg + "<td><p class='text-success'>Y</p></td>";
                    }
                    else
                    {
                        msg = msg + "<td><p class='text-danger'>N</p></td>";
                    }

                    msg = msg + "<td>"
                          + "<a class='btn btn-success' data-ajax='true' data-ajax-success='getMealData' href='" + Url.Action("ModifyGuestMeal", new { id = gm.id }) + "'>Modify</a>"
                          + " <a class='btn btn-danger' data-ajax='true' data-ajax-success='serverResponse' href='" + Url.Action("DeleteGuestMeal", new { id = gm.id }) + "'>Remove</a>"
                          + "</td></tr>";
                    count++;
                }
                msg = msg + "</table>";
            }

            ViewBag.GuestDetailsData     = msg;
            ViewBag.GuestDetailsResponse = response;
        }