Esempio n. 1
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();
                }

            }
        }
Esempio n. 2
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();
                }
            }
        }
Esempio n. 3
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; }
        }
Esempio n. 4
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.");
                }
            }
        }
Esempio n. 5
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; }
 }