public ActionResult DeleteConfirmed(int id)
        {
            Activities activities = db.Activities.Find(id);

            db.Activities.Remove(activities);
            db.SaveChanges();
            return(RedirectToAction("Activities", "AdminManager"));
        }
 public ActionResult Edit([Bind(Include = "ActivityID,Name,Description,Act_Start,Act_End,Price,EmployeeID,CategoryID")] Activities activities)
 {
     if (ModelState.IsValid)
     {
         db.Entry(activities).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Activities", "AdminManager"));
     }
     ViewBag.CategoryID = new SelectList(db.Categories, "CategoryID", "Name", activities.CategoryID);
     ViewBag.EmployeeID = new SelectList(db.Employees, "EmployeeID", "Name", activities.EmployeeID);
     return(View(activities));
 }
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Activities activities = db.Activities.Find(id);

            if (activities == null)
            {
                return(HttpNotFound());
            }
            return(View(activities));
        }
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Activities activities = db.Activities.Find(id);

            if (activities == null)
            {
                return(HttpNotFound());
            }
            ViewBag.CategoryID = new SelectList(db.Categories, "CategoryID", "Name", activities.CategoryID);
            ViewBag.EmployeeID = new SelectList(db.Employees, "EmployeeID", "Name", activities.EmployeeID);
            return(View(activities));
        }
        public ActionResult Sign(int id)
        {
            string user     = User.Identity.GetUserId();
            var    userList = db.Users_Activities.Where(s => s.UserId == user && s.ActivityID == id).FirstOrDefault();

            if (userList == null)
            {
                Activities activities = db.Activities.Find(id);
                db.Users_Activities.Add(new Users_Activities
                {
                    ActivityID = activities.ActivityID,
                    UserId     = User.Identity.GetUserId()
                });
                db.SaveChanges();
                ViewBag.Error = null;
            }
            else
            {
                ModelState.AddModelError("Error", "Jesteś już zapisany na te zajęcia");
                return(View(db.Activities.Find(id)));
            }

            return(RedirectToAction("Index", "UserManager"));
        }