コード例 #1
0
ファイル: EventSrv.cs プロジェクト: arunghosh/alumni-network
 public void UpdateStatus(int id, InviteStatusTypes status)
 {
     var user = _db.Users.Find(CurrUserId);
     var invitee = _db.EventInvitees.SingleOrDefault(i => i.UserId == user.UserId && i.EventId == id);
     if (invitee == null)
     {
         invitee = new EventInvitee
             {
                 UserId = user.UserId,
                 UserName = user.FullName,
                 Status = status,
                 EventId = id
             };
         _db.EventInvitees.Add(invitee);
     }
     else
     {
         invitee.Status = status;
         invitee.Date = DateTime.UtcNow;
         _db.Entry(invitee).State = System.Data.EntityState.Modified;
     }
     _db.SaveChanges();
 }
コード例 #2
0
ファイル: EventSrv.cs プロジェクト: arunghosh/alumni-network
 private void UpdateInvitees(Event info, IEnumerable<int> newList)
 {
     var oldInvites = _db.EventInvitees.Where(e => e.EventId == info.EventId).ToList();
     var oldList = oldInvites.Select(i => i.UserId).ToList();
     foreach (var newId in newList)
     {
         if (!oldList.Contains(newId))
         {
             var user = _db.Users.Find(newId);
             var map = new EventInvitee
             {
                 UserId = user.UserId,
                 UserName = user.FullName,
                 EventId = info.EventId
             };
             _db.EventInvitees.Add(map);
         }
     }
     foreach (var old in oldInvites)
     {
         if (!newList.Contains(old.UserId))
         {
             _db.Entry(old).State = System.Data.EntityState.Deleted;
         }
     }
     info.Invitees = null;
 }
コード例 #3
0
 public JsonResult UpdateStatus(EventInvitee model)
 {
     _srv.UpdateStatus(model.EventId, model.Status);
     var evnt = _db.Events.Include(e => e.Invitees).Single(e => e.EventId == model.EventId);
     var result = new
     {
         gnCnt = evnt.GoingCnt,
         ngCnt = evnt.NotGoingCnt,
         mbCnt = evnt.MayBeCnt,
     };
     return Json(result);
 }