コード例 #1
0
        public IActionResult Index(string email, string code)
        {
            ViewBag.email = email;

            if (CurrentUser != null)
            {
                return(Redirect("/home/dashboard"));
            }

            bool showCode = !string.IsNullOrEmpty(email);

            if (!string.IsNullOrEmpty(email) && !email.EndsWith("@gatech.edu"))
            {
                ViewBag.error = "Only emails with @gatech.edu are allowed!";
                return(View("Login"));
            }

            if (!string.IsNullOrEmpty(code))
            {
                if (code == CurrentCode)
                {
                    // Login
                    CurrentUser = new Models.UserModel(email);
                    userBLL.AddIfDoesntExist(email);
                    return(Redirect("/home/dashboard"));
                }
                else
                {
                    // Fail
                    ViewBag.error = "Incorect code!";
                    return(View("Login"));
                }
            }
            else if (showCode)
            {
                if (isDevelop)
                {
                    CurrentUser = new Models.UserModel(email);
                    userBLL.AddIfDoesntExist(email);
                    return(Redirect("/home/dashboard"));
                }

                Random generator = new Random();
                String newCode   = generator.Next(0, 999999).ToString("D6");
                CurrentCode = newCode;
                Email.Instance.Send(email, "Email from GatechPF", "Your new code is: " + newCode);
            }

            return(View("Login", showCode));
        }
コード例 #2
0
        public void GetInvites()
        {
            ItemView iv      = new ItemView(1000);
            var      invites = service.FindItems(WellKnownFolderName.Calendar, iv).Result;

            if (invites.Count() > 0)
            {
                service.LoadPropertiesForItems(invites, PropertySet.FirstClassProperties);

                foreach (Appointment item in invites)
                {
                    string externalId = item.Id.ToString();

                    string check = "SELECT COUNT(*) FROM Meeting WHERE externalId = @extId";
                    if (Database.NewConnection.ExecuteScalar <int>(check, new { extId = externalId }) > 0)
                    {
                        continue;
                    }

                    string name = item.Subject;

                    string sender     = service.ResolveName(item.Organizer.Address, ResolveNameSearchLocation.DirectoryOnly, true).Result[0].Mailbox.Address;
                    var    attendents = item.RequiredAttendees;

                    string sql          = "INSERT into Meeting (name, externalid, datetime, location) VALUES (@name, @extid, @dt, @loc);SELECT LAST_INSERT_ID();";
                    int    newMeetingId = Database.NewConnection.Query <int>(sql, new { name = name, extid = externalId, dt = item.Start, loc = item.Location }).Single();

                    Business.Feedback feedbackBLL = new Business.Feedback();
                    Business.User     userBLL     = new Business.User();

                    int toUserId = userBLL.AddIfDoesntExist(sender);
                    foreach (var attendent in attendents)
                    {
                        int fromUserId = userBLL.AddIfDoesntExist(attendent.Address);
                        feedbackBLL.Add(new Models.FeedbackModel()
                        {
                            meetingId = newMeetingId, fromUserId = fromUserId, toUserId = toUserId
                        });
                    }
                }
            }
        }
コード例 #3
0
        public IActionResult Create(CourseModel model, string[] user, int[] role)
        {
            int id = courseBLL.Add(model);

            for (int i = 0; i < user.Length; i++)
            {
                string username = user[i];
                int    roleId   = role[i];

                // Check if we need to add the user
                int userID = userBLL.AddIfDoesntExist(username);

                // Add to course with a role
                courseBLL.AddUserToCourse(id, userID, roleId);
            }

            return(Redirect("/Course/List"));
        }