예제 #1
0
        public ActionResult Create(DateTime date, int programId, DateTime monday, FormCollection collection)
        {
            try
            {
                int    mealTypeId  = int.Parse(collection["MealTypeId"]);
                string description = collection["Description"];
                int    recurring   = int.Parse(collection["Recurring"]);

                DateTime startTime = date;
                //ovo sedmicno gleda
                for (int j = 1; j <= recurring; j++)
                {
                    //U istom danu da nadodaje meal
                    int newId = mealDAO.Create(programId, mealTypeId, startTime, description);

                    startTime = startTime.AddDays(7);
                }

                DateTime sunday = monday.AddDays(6);
                return(RedirectToAction("MealPlanForProgram", new { programId = programId, monday = monday, sunday = sunday }));
            }
            catch
            {
                return(View());
            }
        }