Ejemplo n.º 1
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();
         }
     }
 }
Ejemplo n.º 2
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();
                }

            }
        }
Ejemplo n.º 3
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();
            }
        }
Ejemplo n.º 4
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();
                }
            }
        }
Ejemplo n.º 5
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();
                }
            }
        }
Ejemplo n.º 6
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; }
        }
Ejemplo n.º 7
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; }
 }
Ejemplo n.º 8
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.");
                }
            }
        }
Ejemplo n.º 9
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();
                }
            }
        }
Ejemplo n.º 10
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; }
 }
Ejemplo n.º 11
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; }
 }