Ejemplo n.º 1
0
        public JsonResult CreateMany(ActivitySchedule actSched, string userName)
        {
            UpdateModel(actSched); // copy values from form to object. why this is necessary if the object is being passed as arg, I don't know.
            Activity firstActivity = serv.Get(actSched.firstID);
            var instances = actSched.stopDate.Subtract(actSched.dateStart).Days;
            var length = actSched.dateEnd.Subtract(actSched.dateStart).TotalMinutes;

            for (var i = 0; i <= instances; ++i) // This should skip right over firstAct.
            {
                var date = actSched.dateStart.AddDays(i);
                var day = (int)date.DayOfWeek;

                if (day == 0 && !actSched.sunday) ;
                else if (day == 1 && !actSched.monday) ;
                else if (day == 2 && !actSched.tuesday) ;
                else if (day == 3 && !actSched.wednesday) ;
                else if (day == 4 && !actSched.thursday) ;
                else if (day == 5 && !actSched.friday) ;
                else if (day == 6 && !actSched.saturday) ;
                else
                {
                    var activ = new Activity();
                    activ.name = actSched.name;
                    activ.type = actSched.type;
                    activ.dateStart = date;
                    activ.dateEnd = date.AddMinutes(length);
                    activ.recurring = true;
                    activ.firstID = firstActivity.ID;
                    activ.teacher = actSched.teacher;
                    activ.notes = actSched.notes;

                    Activity act = serv.Create(activ, userName);
                }
            }

            return Json(new
            {
                sNewRef = EditTabRef(firstActivity),
                sNewLabel = EditTabLabel(firstActivity),
                iNewID = firstActivity.ID,
                jobSuccess = true
            },
            JsonRequestBehavior.AllowGet);
        }
Ejemplo n.º 2
0
 public ActionResult CreateMany(int id)
 {
     Activity firstAct = serv.Get(id);
     var _model = new ActivitySchedule(firstAct);
     return PartialView("CreateMany", _model);
 }