コード例 #1
0
 public ActionResult Login(string txtUserName, string txtPassword)
 {
     // Lets first check if the Model is valid or not
     using (EventAppDataModelEntity entities = new EventAppDataModelEntity())
     {
         try
         {
             ValidateUserDTO retObject = new ValidateUserDTO();
             string          UserName  = "******" + txtUserName;
             using (PrincipalContext pCtx = new PrincipalContext(ContextType.Domain, "0.0.0.0", UserName, txtPassword))
             {
                 FormsAuthentication.SetAuthCookie(UserName, false);
                 GroupPrincipal group = GroupPrincipal.FindByIdentity(pCtx, "USERS");
                 var            user  = UserPrincipal.FindByIdentity(pCtx, UserName);
                 retObject.FirstName = user.GivenName;
                 retObject.LastName  = user.Surname;
                 retObject.Name      = user.DisplayName;
                 retObject.EmpId     = user.EmployeeId;
                 retObject.EmailId   = user.SamAccountName + "@doaminname.com";
                 Session["Username"] = user.DisplayName;
                 return(RedirectToAction("SendPushNotification", "PushNotification"));
             }
         }
         catch (Exception ex)
         {
             //string output = "Message: " + ex.Message + Environment.NewLine + "Stack Trace: " + ex.StackTrace;
             ViewBag.Message = "Invalid User Credentials";
             return(View());
         }
     }
 }
コード例 #2
0
        // private IUserRepository userRepository;


        #region Private variables

        //private static string NOTIFICATION_HUB_NAME = ConfigurationManager.AppSettings["NOTIFICATION_HUB_NAME"];
        //private static string NOTIFICATION_HUB_FULL_ACCESS_CONNECTION_STRING = ConfigurationManager.AppSettings["NOTIFICATION_HUB_FULL_ACCESS_CONNECTION_STRING"];
        #endregion

        public PushNotificationController()
        {
            var context = new EventAppDataModelEntity();

            //PlaybookContext context = new PlaybookContext();
            //userRepository = new UserRepository(context);
        }
コード例 #3
0
        public List <NotificationOutput> GetNotificationsAfter(int lastRetrievedNotificationId)
        {
            var getNotifications = new List <NotificationModel>();
            var nOutput          = new List <NotificationOutput>();

            using (var context = new EventAppDataModelEntity())
            {
                getNotifications = (from b in context.Notifications.Where(e => e.NotificationId > lastRetrievedNotificationId).OrderByDescending(e => e.NotificationId)
                                    select new NotificationModel()
                {
                    Id = b.NotificationId,
                    content = b.Message,
                    title = b.Title,
                    sentAt = b.CreatedOn
                }).ToList();

                foreach (NotificationModel nm in getNotifications)
                {
                    nOutput.Add(new NotificationOutput()
                    {
                        content = nm.content + " ID: " + nm.Id.ToString(),
                        title   = nm.title,
                        sentAt  = TimeZoneInfo.ConvertTimeFromUtc(nm.sentAt.GetValueOrDefault(), INDIAN_ZONE).ToString("dd MMM yyyy hh:mm tt")
                    });
                }
            }
            return(nOutput);
        }
コード例 #4
0
        // GET api/<controller>
        public THClueDetails GetCluesByUserId(int userId, int tHClueCategoryId)
        {
            List <THClueDetails> tHClueDetailsList = new List <THClueDetails>();
            const int            EmpIDLength       = 5;
            var empId = userId.ToString().PadLeft(EmpIDLength, '0');

            using (var context = new EventAppDataModelEntity())
            {
                var userDetails = (from t in context.THTeams
                                   join tc in context.THTeamClues on t.THTeamId equals tc.THTeamID
                                   join c in context.THClues on tc.THClueID equals c.THClueId
                                   join cc in context.THClueCategories on c.THClueCategoryId equals cc.THClueCategoryId
                                   join u in context.Users on t.THTeamId equals u.THTeamId
                                   join l in context.Locations on t.LocationId equals l.LocationId

                                   where u.EmpID == empId && cc.THClueCategoryId == tHClueCategoryId
                                   select new
                {
                    THTeamID = t.THTeamId,
                    THTeamDescription = t.THTeamDescription,
                    THClueID = c.THClueId,
                    THClueDescription = c.THCluesDescription,
                    IsValid = tc.IsValid,
                    UserName = u.FirstName + " " + u.LastName,
                    LocationDescription = l.Name,
                    ThRiddle = c.THRiddle,
                    MemberNames = t.MemberNames
                }).FirstOrDefault();
                THClueDetails tHclueDetails = new THClueDetails()
                {
                    IsValid = false, UserName = "******", LocationDescription = string.Empty, THClueDescription = string.Empty, THTeamDescription = string.Empty
                };
                if (userDetails != null)
                {
                    tHclueDetails.THTeamID            = userDetails.THTeamID;
                    tHclueDetails.THTeamDescription   = userDetails.THTeamDescription;
                    tHclueDetails.THClueID            = userDetails.THClueID;
                    tHclueDetails.THClueDescription   = userDetails.THClueDescription;
                    tHclueDetails.IsValid             = (bool)userDetails.IsValid;
                    tHclueDetails.LocationDescription = userDetails.LocationDescription;
                    tHclueDetails.UserName            = userDetails.UserName;
                    tHclueDetails.THRiddle            = userDetails.ThRiddle;
                    tHclueDetails.MembersName         = userDetails.MemberNames;
                }
                tHClueDetailsList.Add(tHclueDetails);
            }

            return(tHClueDetailsList.FirstOrDefault());
        }
コード例 #5
0
        // GET api/<controller>
        public List <RateSessionsDTO> Get()
        {
            using (var context = new EventAppDataModelEntity())
            {
                var rateSession = (from b in context.UserReviews
                                   select new RateSessionsDTO()
                {
                    UserId = b.UserId,
                    SessionId = b.SessionId,
                    Rating = b.Rating,
                    Comments = b.Comments
                }).ToList();

                return(rateSession);
            }
        }
コード例 #6
0
        public long SaveNotifications(PushNotification model)
        {
            long result          = -1;
            var  message         = "{\"data\":{\"subject\":\"" + model.Subject + "\",\"content\":\"" + model.Body + "\"}}";
            var  context         = new EventAppDataModelEntity();
            var  notificationAdd = new Models.Notification()
            {
                Message = @model.Body, Title = @model.Subject, CreatedOn = DateTime.UtcNow
            };

            context.Notifications.Add(notificationAdd);
            context.SaveChanges();
            result = notificationAdd.NotificationId;
            return(result);
            // return result;
        }
コード例 #7
0
        // GET api/<controller>
        public IHttpActionResult Get()
        {
            using (var context = new EventAppDataModelEntity())
            {
                var st = (from b in context.Stalls.Where(e => e.StallId != 99).ToList()
                          select new StallDTO()
                {
                    StallId = b.StallId,
                    Title = b.Title,
                    Description = b.Description,
                    BeaconId = b.BeaconId ?? 0
                }).ToList();


                return(Ok(st));
            }
        }
コード例 #8
0
        public IHttpActionResult GetSpeakerList()

        {
            using (var context = new EventAppDataModelEntity())
            {
                var speakerList = (from b in context.Speakers
                                   select new SpeakerDTO()
                {
                    SpeakerId = b.SpeakerId,
                    FirstName = b.FirstName,
                    LastName = b.LastName,
                    Intro = b.Intro,
                    Description = b.Description,
                    Image = b.Image
                }).Where(e => e.SpeakerId != 99).ToList();
                return(Ok(speakerList));
            }
        }
コード例 #9
0
        // GET api/<controller>
        public IHttpActionResult Get()
        {
            using (var context = new EventAppDataModelEntity())
            {
                var tags = (from t in context.Tags
                            join td in context.TagDetails on t.TagId equals td.TagId

                            where t.TagId == td.TagId

                            select new TagDTO()
                {
                    TagId = t.TagId,
                    Title = t.Title,
                    Description = t.Description,
                    SessionId = td.SessionId,
                    SessionCount = t.TagDetails.Where(e => e.SessionId == td.SessionId).Count()
                }).ToList();


                return(Ok(tags));
            }
        }
コード例 #10
0
        public IHttpActionResult ReportForRate()
        {
            DateTime dateStartTime = DateTime.MinValue;
            List <ReportForRates> uSessionRateReport = new List <ReportForRates>();

            using (var context = new EventAppDataModelEntity())
            {
                var reprtSessionRate = (from b in context.UserReviews
                                        join u in context.Users on b.UserId equals u.UserId
                                        join s in context.Sessions on b.SessionId equals s.SessionId
                                        select new
                {
                    UserId = b.UserId,
                    SessionId = b.SessionId,
                    Rating = b.Rating,
                    FirstName = u.FirstName,
                    LastName = u.LastName,
                    Date = s.StartDate,
                    Time = s.StartTime
                }).ToList();

                foreach (var i in reprtSessionRate)
                {
                    ReportForRates rFS = new ReportForRates();
                    rFS.UserId    = i.UserId;
                    rFS.SessionId = i.SessionId;
                    rFS.Rating    = i.Rating;
                    rFS.FirstName = i.FirstName;
                    rFS.LastName  = i.LastName;
                    rFS.Date      = i.Date.ToString("dd MMM yyyy");

                    rFS.Time = dateStartTime.Add(i.Time).ToString("hh:mm tt", CultureInfo.InvariantCulture);

                    uSessionRateReport.Add(rFS);
                }

                return(Ok(uSessionRateReport));
            }
        }
コード例 #11
0
        public IHttpActionResult ReportForSession()
        {
            DateTime dateStartTime = DateTime.MinValue;
            List <ReportUserSession> reportUserSession = new List <ReportUserSession>();

            using (var context = new EventAppDataModelEntity())
            {
                dateStartTime = DateTime.MinValue;
                var uSessionReport = (from b in context.UserSessions
                                      join u in context.Users on b.UserID equals u.UserId
                                      join s in context.Sessions on b.SessionID equals s.SessionId
                                      where u.UserId == b.UserID && s.SessionId == b.SessionID
                                      select new
                {
                    SessionID = b.SessionID,
                    UserID = b.UserID,
                    IsInterested = b.Isinterested,
                    Date = s.StartDate,
                    Time = s.StartTime,
                    FirstName = u.FirstName,
                    LastName = u.LastName
                }).ToList();

                foreach (var u in uSessionReport)
                {
                    ReportUserSession ruS = new ReportUserSession();
                    ruS.SessionID    = u.SessionID;
                    ruS.UserID       = u.UserID;
                    ruS.IsInterested = u.IsInterested;
                    ruS.Date         = u.Date.ToString("dd MMM yyyy");
                    ruS.Time         = dateStartTime.Add(u.Time).ToString("hh:mm tt", CultureInfo.InvariantCulture);
                    ruS.FirstName    = u.FirstName;
                    ruS.LastName     = u.LastName;
                    reportUserSession.Add(ruS);
                }

                return(Ok(reportUserSession));
            }
        }
コード例 #12
0
        public IHttpActionResult UpdateTHClueDetails([FromBody] THClueDetailsSubmitDTO tHClueDetailsSubmitDTO)
        {
            var result = new OutputResult()
            {
                Message = "Failure", IsValid = "False"
            };

            using (var context = new EventAppDataModelEntity())
            {
                var answer = (from s in context.THClues
                              where s.THClueId == tHClueDetailsSubmitDTO.THClueID && s.THClueCategoryId == tHClueDetailsSubmitDTO.THClueCategoryID
                              select s
                              ).FirstOrDefault();
                try
                {
                    if (answer != null)
                    {
                        if ((string.IsNullOrEmpty(answer.THAnswer) && string.IsNullOrEmpty(tHClueDetailsSubmitDTO.Answer))
                            ||
                            (!string.IsNullOrEmpty(tHClueDetailsSubmitDTO.Answer) && !string.IsNullOrEmpty(answer.THAnswer) &&
                             answer.THAnswer.ToLower() == tHClueDetailsSubmitDTO.Answer.ToLower()))
                        {
                            var clueUpdateRecord = context.THTeamClues.Where(e => e.THClueID == tHClueDetailsSubmitDTO.THClueID &&
                                                                             e.THTeamID == tHClueDetailsSubmitDTO.THTeamID).FirstOrDefault();
                            clueUpdateRecord.IsValid = true;
                            context.SaveChanges();
                            result.Message = "Success";
                            result.IsValid = "True";
                            return(Ok(result));
                        }
                    }
                    return(Ok(result));
                }
                catch (Exception)
                {
                    return(Ok(result));
                }
            }
        }