public ActionResult ExitEventConfirmed(int EventId, string id)
        {
            User_Event @user_event = db.User_Event.Where(m => m.EventId == EventId).Where(x => x.UserId == id).First();

            db.User_Event.Remove(@user_event);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
示例#2
0
        public ActionResult ExitEventConfirmed(int id)
        {
            //Event @event = db.Events.Find(id);
            User_Event @user_event = db.User_Event.Where(m => m.EventId == id).First();

            db.User_Event.Remove(@user_event);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
        public ActionResult IncludeConfirmed(int EventId, string id)
        {
            var user_event = new User_Event();

            user_event.UserId  = id;
            user_event.EventId = EventId;
            db.User_Event.Add(@user_event);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
示例#4
0
        public ActionResult IncludeConfirmed(int id)
        {
            Event @event = db.Events.Find(id);

            var userId     = User.Identity.GetUserId();
            var user_event = new User_Event();

            user_event.UserId  = userId;
            user_event.EventId = id;
            db.User_Event.Add(@user_event);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
        public ActionResult CancelVolunteerEvent(int id)
        {
            var loggedUser = User.Identity.GetUserName();
            var users      = db.User.Single(v => v.Email == loggedUser);

            var userEvent = db.User_Event.Single(e => e.VolunteerEventID == id && e.UserID == users.ID);

            User_Event user_event = db.User_Event.Find(userEvent.ID);

            db.User_Event.Remove(userEvent);
            db.SaveChanges();

            return(RedirectToAction("Index"));
        }
        public ActionResult AddUserToEvent(int id)
        {
            var loggedUser = User.Identity.GetUserName();
            var users      = db.User.Single(v => v.Email == loggedUser);

            User_Event user_event = new User_Event
            {
                UserID           = users.ID,
                VolunteerEventID = id
            };

            db.User_Event.Add(user_event);
            db.SaveChanges();

            return(RedirectToAction("Index"));
        }
示例#7
0
 public void AddUser_Event(string userId, string content)
 {
     try
     {
         User_Event addModel = new User_Event()
         {
             Id         = Guid.NewGuid(),
             Content    = StringHelper.LimitLength(content, 500),
             CreateTime = DateTime.Now,
             GoodCount  = 0,
             IsSeen     = true,
             UserId     = StringHelper.LimitLength(userId)
         };
         db.AddToUser_Events(addModel);
         db.SaveChanges();
     }
     catch
     {
         throw new Exception("添加错误");
     }
 }
        public ActionResult Create(VolunteerEvent volunteerEvent)
        {
            var loggedUser = User.Identity.GetUserName();
            var users      = db.User.Single(v => v.Email == loggedUser);

            volunteerEvent.HostID = User.Identity.GetUserId();

            User_Event user_event = new User_Event
            {
                UserID           = users.ID,
                VolunteerEventID = volunteerEvent.ID
            };

            if (ModelState.IsValid)
            {
                db.User_Event.Add(user_event);
                db.VolunteerEvent.Add(volunteerEvent);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(volunteerEvent));
        }