public ActionResult Create(Activity activity, int calenderId = 0)
        {
            if (ModelState.IsValid)
            {
                activity.CalenderId = calenderId;
                var timeSpann = TimeSpan.Parse(activity.Time);
                activity.Date = new DateTime(activity.Date.Year, activity.Date.Month, activity.Date.Day, 0, 0, 0);
                db.Activities.Add(activity);
                db.SaveChanges();
                return RedirectToAction("Index", new { calenderId = calenderId });
            }

            ViewBag.CalenderId = new SelectList(db.Calenders, "Id", "Name", activity.CalenderId);
            return View(activity);
        }
        public ActionResult CreateFromDialog(string jsonData)
        {
            Dictionary<string, string> data = JsonConvert.DeserializeObject<Dictionary<string, string>>(jsonData);

            var activity = new Activity();
            activity.Name = data["name"];
            activity.MaxPerson = int.Parse(data["nrOfPerson"]);
            activity.Duration = int.Parse(data["length"]);
            activity.Description = data["description"];
            activity.CalenderId = int.Parse(data["calenderId"]);

            var timeSpann = TimeSpan.Parse(data["startTime"]);
            var date = DateTime.Parse(data["date"]);
            activity.Date = new DateTime(date.Year, date.Month, date.Day, 0, 0, 0);
            activity.Time = timeSpann.Hours + ":" + timeSpann.ToString(@"mm");

            db.Activities.Add(activity);
            db.SaveChanges();

            return RedirectToAction("ViewWeek", "Calender", new { id = activity.CalenderId, activityDate = activity.Date.ToShortDateString() });
        }
 public ActionResult Edit(Activity activity, string sortOrder = "", int page = 1, int pageSize = 10, string searchString = "")
 {
     if (ModelState.IsValid)
     {
         db.Entry(activity).State = EntityState.Modified;
         db.SaveChanges();
         return RedirectToAction("Index", new { calenderId = activity.CalenderId, page = page, pageSize = pageSize, searchString = searchString, sortOrder = sortOrder });
     }
     ViewBag.CalenderId = new SelectList(db.Calenders, "Id", "Name", activity.CalenderId);
     return View(activity);
 }