public ActionResult Invite(int ID, int UserID, int Type) { var exist = DB.EventPeoples.FirstOrDefault( x => ((x.FromUserID == CurrentUser.ID && x.ToUserID == UserID) || (x.ToUserID == CurrentUser.ID && x.FromUserID == UserID)) && x.Type == Type && x.EventID == ID); if (exist != null) { return(new ContentResult()); } exist = new EventPeople() { FromUserID = CurrentUser.ID, ToUserID = UserID, Type = Type, Status = 0, SendDate = DateTime.Now, EventID = ID }; DB.EventPeoples.InsertOnSubmit(exist); DB.SubmitChanges(); return(new ContentResult()); }
public ActionResult ChangeGoDetails(int ID, int Type) { var ev = DB.EventPeoples.FirstOrDefault( x => (x.FromUserID == CurrentUser.ID || x.ToUserID == CurrentUser.ID) && x.EventID == ID); if (ev != null) { ev.Type = Type; if (ev.Status == 1) { var related = DB.EventPeoples.Where( x => x.FromUserID == CurrentUser.ID && x.ToUserID != CurrentUser.ID && x.Type == 1 && x.EventID == ID); if (related.Any()) { DB.EventPeoples.DeleteAllOnSubmit(related); } DB.EventPeoples.DeleteOnSubmit(ev); } else { ev.Status = 1; } } else { ev = new EventPeople() { Status = 1, Type = Type, FromUserID = CurrentUser.ID, SendDate = DateTime.Now, EventID = ID }; DB.EventPeoples.InsertOnSubmit(ev); } DB.SubmitChanges(); return(PartialView(DB.Events.First(x => x.ID == ID))); }