Exemple #1
0
 private void LoadUsers()
 {
     using (var context = new UzoneEntities())
     {
         List<RegisteredUser> _users;
         _users = context.Set<RegisteredUser>().ToList();
         UsersGrid.DataSource = _users;
     }
 }
Exemple #2
0
 protected void RadScheduler1_AppointmentDelete(object sender, SchedulerCancelEventArgs e)
 {
     using (var context = new UzoneEntities())
     {
         Scheduler _scheduler;
         _scheduler = context.Schedulers.Find(e.Appointment.ID);
         if (_scheduler != null)
         {
             context.Schedulers.Remove(_scheduler);
             context.SaveChanges();
         }
     }
 }
Exemple #3
0
        private Boolean CheckEmailAvailability(string email)
        {
            using (var context = new UzoneEntities())
            {
                var founduser = (from ru in context.RegisteredUsers
                                 where ru.Email == email
                                 select ru);

                if (founduser.Any())
                    return false;
                else return true;
            }
        }
Exemple #4
0
        protected void LocationGrid_UpdateCommand(object sender, Telerik.Web.UI.GridCommandEventArgs e)
        {
            var editableItem = ((GridEditableItem)e.Item);
            var locationID = (int)editableItem.GetDataKeyValue("EventLocationID");

            using (var context = new UzoneEntities())
            {
                EventLocation _location;
                _location = context.EventLocations.Find(locationID);
                if (_location != null && Session["currentSchoolID"] != null)
                {
                    editableItem.UpdateValues(_location);
                    context.EventLocations.Attach(_location);
                    context.Entry(_location).State = EntityState.Modified;
                    context.SaveChanges();
                }
            }
        }
Exemple #5
0
        protected void LocationGrid_DeleteCommand(object sender, Telerik.Web.UI.GridCommandEventArgs e)
        {
            var locationID = (int)((GridDataItem)e.Item).GetDataKeyValue("EventLocationID");

            using (var context = new UzoneEntities())
            {
                EventLocation _location;
                _location = context.EventLocations.Find(locationID);
                if (_location != null)
                {
                    _location.Active = false;
                    context.EventLocations.Attach(_location);
                    context.Entry(_location).State = EntityState.Modified;
                    context.SaveChanges();
                }

            }
        }
Exemple #6
0
        protected void RadScheduler1_AppointmentInsert(object sender, SchedulerCancelEventArgs e)
        {
            Scheduler _scheduler = new Scheduler();
            _scheduler.EventStart = e.Appointment.Start;
            _scheduler.EventEnd = e.Appointment.End;
            _scheduler.EventDescription = e.Appointment.Description;
            _scheduler.EventSubject = e.Appointment.Subject;
            _scheduler.SchoolID = (long)Session["currentSchoolID"];
            if (e.Appointment.Resources.FirstOrDefault() != null)
                _scheduler.EventLocationID = (int)e.Appointment.Resources.First().Key;

            using (var context = new UzoneEntities())
            {
                context.Schedulers.Add(_scheduler);
                context.SaveChanges();

                LoadScheduler();
            }
        }
Exemple #7
0
        protected void checkEmail_Click(object sender, EventArgs e)
        {
            using (var context = new UzoneEntities())
            {
                RegisteredUser foundUser = (from fu in context.RegisteredUsers
                                            where fu.Email == txtEmailAddress.Value
                                            select fu).FirstOrDefault();

                if (foundUser != null)
                {
                    rwSecurity.Style.Add("visibility", "visible");
                    SendEmail.Visible = true;
                    checkEmail.Visible = false;
                    lbSecurityQuestion.InnerText = context.LockedQuestions.Find(foundUser.LockedQuestionID).Question;
                }
                else
                    CreateErrorMsg("The specified email address was not found.  Please check and try again.");

            }
        }
Exemple #8
0
        protected void LocationGrid_InsertCommand(object sender, Telerik.Web.UI.GridCommandEventArgs e)
        {
            var editableItem = ((GridEditableItem)e.Item);
            Hashtable values = new Hashtable();
            editableItem.ExtractValues(values);

            EventLocation _location = new EventLocation();
            _location.EventLocationName = values["EventLocationName"].ToString();
            _location.Active = true;

            using (var context = new UzoneEntities())
            {
                if (Session["currentSchoolID"] != null)
                {
                    var currentSchool = (long)Session["currentSchoolID"];
                    _location.SchoolID = currentSchool;
                    context.EventLocations.Add(_location);
                    context.SaveChanges();
                }
            }
        }
Exemple #9
0
        protected void RadScheduler1_AppointmentUpdate(object sender, AppointmentUpdateEventArgs e)
        {
            using (var context = new UzoneEntities())
            {
                Scheduler _scheduler;
                _scheduler = context.Schedulers.Find(e.Appointment.ID);
                if (_scheduler != null)
                {
                    _scheduler.EventStart = e.ModifiedAppointment.Start;
                    _scheduler.EventEnd = e.ModifiedAppointment.End;
                    _scheduler.EventDescription = e.ModifiedAppointment.Description;
                    _scheduler.EventSubject = e.ModifiedAppointment.Subject;
                    _scheduler.SchoolID = (long)Session["currentSchoolID"];
                    if (e.Appointment.Resources.FirstOrDefault() != null)
                        _scheduler.EventLocationID = (int)e.Appointment.Resources.First().Key;
                    context.SaveChanges();

                    LoadScheduler();
                }
            }
        }
Exemple #10
0
 protected void SendEmail_Click(object sender, EventArgs e)
 {
     var typeOfForgot = Request.QueryString["forgot"];
     using (var context = new UzoneEntities())
     {
         RegisteredUser foundUser = (from fu in context.RegisteredUsers
                                     where fu.Email == txtEmailAddress.Value &&
                                     fu.LockedAnswer == txtSecurityAnswer.Value
                                     select fu).FirstOrDefault();
         if (foundUser != null)
         {
             if (typeOfForgot == "forgotpassword")
                 resetAndSend(txtEmailAddress.Value);
             else if (typeOfForgot == "forgotusername")
                 sendUsername(txtEmailAddress.Value);
             else
                 CreateErrorMsg("There was an issue accessing your account.  Please try again.");
         }
         else
             CreateErrorMsg("The email and security answer combination does not exist.  Please try again.");
     }
 }
Exemple #11
0
        private Boolean UserLogin()
        {
            using (var context = new UzoneEntities())
            {
                var founduser = (from ru in context.RegisteredUsers
                                 where ru.UserName == txtUser.Value
                                 && ru.Password == txtPassword.Value
                                 select ru);

                if (founduser.FirstOrDefault() != null)
                {
                    Session["userName"] = founduser.First().UserName;
                    Session["currentSchool"] = context.Schools.FirstOrDefault(x => x.SchoolID == founduser.FirstOrDefault().SchoolID).Name;
                    Session["currentSchoolID"] = founduser.First().SchoolID;
                    Session["isLogged"] = "true";
                    Session["userRole"] = founduser.First().UserRoleID;
                    Session["timeStamp"] = DateTime.Now;
                    return true;
                }
                else return false;
            }
        }
Exemple #12
0
 private void LoadResources()
 {
     using (var context = new UzoneEntities())
     {
         if (Session["currentSchoolID"] != null)
         {
             var currentSchool = (long)Session["currentSchoolID"];
             if (RadScheduler1.ResourceTypes.FirstOrDefault() == null)
             {
                 List<EventLocation> _locations;
                 _locations = context.Set<EventLocation>().Where(l => l.SchoolID == currentSchool).ToList();
                 ResourceType _item = new ResourceType();
                 _item.DataSource = _locations;
                 _item.ForeignKeyField = "SchoolID";
                 _item.KeyField = "EventLocationID";
                 _item.TextField = "EventLocationName";
                 _item.Name = "Location";
                 RadScheduler1.ResourceTypes.Add(_item);
             }
         }
     }
 }
Exemple #13
0
        private Boolean CheckUsernameAvailability(string username)
        {
            using (var context = new UzoneEntities())
            {
                var founduser = (from ru in context.RegisteredUsers
                                 where ru.UserName == username
                                 select ru);

                if (founduser.Any())
                    return false;
                else return true;
            }
        }
Exemple #14
0
        private Boolean UpdateAccount(RegisteredUser user)
        {
            try
            {
                using (var context = new UzoneEntities())
                {
                    string _currentUsername = Session["userName"].ToString();
                    user.UserID = context.RegisteredUsers.FirstOrDefault(c => c.UserName == _currentUsername).UserID;
                }

                using (var context = new UzoneEntities())
                {
                    context.RegisteredUsers.Attach(user);
                    context.Entry(user).State = EntityState.Modified;
                    context.SaveChanges();
                }
                return true;
            }
            catch (Exception ex)
            { return false; }
        }
Exemple #15
0
 private void LoadSecurityQuestion()
 {
     using (var context = new UzoneEntities())
     {
         List<LockedQuestion> _questions;
         _questions = context.Set<LockedQuestion>().ToList();
         comboSecurityQues.DataSource = _questions;
         comboSecurityQues.DataBind();
     }
 }
Exemple #16
0
 private void LoadSchool()
 {
     using (var context = new UzoneEntities())
     {
         List<School> _schools;
         _schools = context.Set<School>().ToList();
         comboSchool.DataSource = _schools;
         comboSchool.DataBind();
     }
 }
Exemple #17
0
        private void LoadRegistration()
        {
            using (var context = new UzoneEntities())
            {
                RegisteredUser _user = new RegisteredUser();
                string _currentUsername = Session["userName"].ToString();
                _user = (from ru in context.RegisteredUsers
                         where ru.UserName == _currentUsername
                         select ru).FirstOrDefault();

                if (_user != null)
                {
                    txtName.Text = _user.Name;
                    txtUsername.Text = _user.UserName;
                    txtPassword.Text = _user.Password;
                    txtConfirmPass.Text = _user.Password;
                    txtEmail.Text = _user.Email;
                    comboSchool.SelectedValue = _user.SchoolID.ToString();
                    comboSecurityQues.SelectedValue = _user.LockedQuestionID.ToString();
                    txtSecurityAns.Text = _user.LockedAnswer;
                    chkTerms.Checked = true;
                }
            }
        }
Exemple #18
0
 private Boolean CreateAccount(RegisteredUser user)
 {
     try
     {
         using (var context = new UzoneEntities())
         {
             context.RegisteredUsers.Add(user);
             context.SaveChanges();
         }
         return true;
     }
     catch (Exception ex)
     { return false; }
 }
Exemple #19
0
 private Boolean CreateSchool(School school)
 {
     try
     {
         using (var context = new UzoneEntities())
         {
             context.Schools.Add(school);
             context.SaveChanges();
         }
         return true;
     }
     catch (Exception ex)
     { return false; }
 }
Exemple #20
0
        private void LoadSchools(long id)
        {
            using (var context = new UzoneEntities())
            {
                School _schools;
                _schools = (from sc in context.Schools
                            where sc.SchoolID == id
                            select sc).FirstOrDefault();

                if (_schools != null)
                {
                    txtFullName.Text = _schools.Name;
                    txtAlias.Text = _schools.Alias;
                    txtMascot.Text = _schools.Mascot;
                    txtAddress.Text = _schools.Address;
                    txtCity.Text = _schools.City;
                    txtZip.Text = _schools.Zip;
                    txtContactEmail.Text = _schools.Email;
                    txtContactPhone.Text = _schools.Phone;
                    comboState.SelectedValue = _schools.State;
                    rdColorBackground.SelectedColor = ColorTranslator.FromHtml(_schools.BannerColor);
                    rdColorPrimary.SelectedColor = ColorTranslator.FromHtml(_schools.ButtonColor);
                }
            }
        }
Exemple #21
0
 private void LoadLocations()
 {
     using (var context = new UzoneEntities())
     {
         if (Session["currentSchoolID"] != null)
         {
             var currentSchool = (long)Session["currentSchoolID"];
             List<EventLocation> _locations;
             _locations = context.Set<EventLocation>().Where(l => l.SchoolID == currentSchool && l.Active == true).ToList();
             LocationGrid.DataSource = _locations;
         }
         else
         {
             List<EventLocation> _locations = new List<EventLocation>();
             LocationGrid.DataSource = _locations;
         }
     }
 }
Exemple #22
0
 private Boolean UpdateSchool(School school)
 {
     try
     {
         using (var context = new UzoneEntities())
         {
             context.Schools.Attach(school);
             context.Entry(school).State = EntityState.Modified;
             context.SaveChanges();
         }
         return true;
     }
     catch (Exception ex)
     { return false; }
 }
Exemple #23
0
 private void LoadScheduler()
 {
     using (var context = new UzoneEntities())
     {
         if (Session["currentSchoolID"] != null)
         {
             var currentSchool = (long)Session["currentSchoolID"];
             List<Scheduler> _schedulers;
             _schedulers = context.Set<Scheduler>().Where(s => s.SchoolID == currentSchool).ToList();
             RadScheduler1.DataSource = _schedulers;
         }
     }
 }
Exemple #24
0
        private Boolean emailExist(string emailAddress)
        {
            using (var context = new UzoneEntities())
            {
                var foundEmail = (from fe in context.RegisteredUsers
                                  where fe.Email == emailAddress
                                  select fe);

                if (foundEmail.Any())
                    return true;
                else return false;
            }
        }
Exemple #25
0
        private void resetAndSend(string emailAddress)
        {
            using (var context = new UzoneEntities())
            {
                RegisteredUser foundUser = (from fu in context.RegisteredUsers
                                            where fu.Email == emailAddress
                                            select fu).FirstOrDefault();

                if (foundUser != null)
                {
                    foundUser.Password = CreateRandomPassword();
                    context.RegisteredUsers.Attach(foundUser);
                    context.Entry(foundUser).State = EntityState.Modified;
                    context.SaveChanges();
                    sendMail(foundUser.Email, foundUser.Name, "Here is your new password: "******".  Once you login, use the manage profile module to reset your password.");
                }
            }
        }
Exemple #26
0
        private void sendUsername(string emailAddress)
        {
            using (var context = new UzoneEntities())
            {
                RegisteredUser foundUsername = (from fu in context.RegisteredUsers
                                                where fu.Email == emailAddress
                                                select fu).FirstOrDefault();

                if (foundUsername != null)
                    sendMail(foundUsername.Email, foundUsername.Name, "Here is your username: " + foundUsername.UserName);
            }
        }