Beispiel #1
0
        public void DbGetTest()
        {
            var options = new DbContextOptionsBuilder <InvitationsDbContext>()
                          .UseInMemoryDatabase(databaseName: "DbGetTestDatabase")
                          .Options;

            using (var context = new InvitationsDbContext(options))
            {
                context.Invitations.Add(new Invitation {
                    Phone = "79998887766", Author = 4
                });
                context.Invitations.Add(new Invitation {
                    Phone = "79998887765", Author = 4
                });
                context.Invitations.Add(new Invitation {
                    Phone = "79998887764", Author = 4
                });
                context.SaveChanges();
            }

            using (var context = new InvitationsDbContext(options))
            {
                var        invitationRepository = new InvitationRepository(context);
                Invitation invitation           = invitationRepository.Get(1);

                Assert.NotNull(invitation);
            }
        }
Beispiel #2
0
        private void updateInvitationStatus(User currentUser, int meetingId, int newStatus)
        {
            Invitation updatedInvite = new Invitation();

            foreach (var invitation in InvitationRepository.Get(currentUser.Id))
            {
                if (invitation.Meeting.Id == meetingId)
                {
                    updatedInvite = invitation;
                }
            }
            updatedInvite.Status = newStatus;
            InvitationRepository.Update(updatedInvite);
        }
Beispiel #3
0
        // GET: Invitation
        public ActionResult Index()
        {
            int userId      = Convert.ToInt32(User.Identity.GetUserId());
            var invitations = InvitationRepository.Get(userId);
            var model       = new InvitationViewModel()
            {
                Invitations = invitations
            };

            if (invitations != null)
            {
                InvitationRepository.UpdateNotified(userId);
            }
            return(View(model));
        }
Beispiel #4
0
        // GET: Meetings
        public ActionResult Index()
        {
            int userId   = Convert.ToInt32(User.Identity.GetUserId());
            var meetings = MeetingsRepository.Get(userId);

            meetings.Reverse();
            var invitations = InvitationRepository.Get(userId);

            invitations.Reverse();
            if (invitations != null)
            {
                InvitationRepository.UpdateNotified(userId);
            }
            var model = new MeetingsViewModel()
            {
                Meetings    = meetings,
                Invitations = invitations
            };

            return(View(model));
        }
        // Function to get the meeting invitation count for dynamic updating notifications
        public IHttpActionResult GetNotifications()
        {
            var count = 0;

            try
            {
                var invitations = InvitationRepository.Get(Convert.ToInt32(User.Identity.GetUserId()));
                foreach (var x in invitations)
                {
                    if (x.Notified == false)
                    {
                        count++;
                    }
                }
            }
            catch (Exception ex)
            {
                Console.Write(ex.Message);
            }
            return(Json(count));
        }
 public ActionResult<Invitation> GetById(int id)
 {
     Invitation invitation = _invitationRepository.Get(id);
     return invitation != null ? (ActionResult<Invitation>)Ok(invitation) : NotFound();
 }