public static void EditUser(int id, string passWord) { using (var ef = new CMSDbEntities()) { var user = ef.AdminLogins.Find(id); if (user != null) { user.pass = passWord; ef.SaveChanges(); } } }
public static void DeleteUser(int id) { using (var ef = new CMSDbEntities()) { var user = ef.AdminLogins.Find(id); if (user != null) { ef.AdminLogins.Remove(user); ef.SaveChanges(); } } }
public static void AddUser(string userName, string passWord, int pageId) { using (var ef = new CMSDbEntities()) { AdminLogin al = new AdminLogin(); al.PageSettingId = pageId; al.pass = passWord; al.user = userName; ef.AdminLogins.Add(al); ef.SaveChanges(); } }
public ActionResult DeleteGalleryImage(int id) { using (var ef = new CMSDbEntities()) { var image = ef.GalleryImages.Find(id); if (image != null) { ef.ImageFullSizes.Remove(image.ImageFullSize); ef.GalleryImages.Remove(image); ef.SaveChanges(); } } return this.Redirect(this.Request.UrlReferrer.ToString()); }
public ActionResult EditPass(FormCollection collection) { if (collection != null) { var uid = Convert.ToInt32(collection["ThisId"], CultureInfo.CurrentCulture); ViewBag.ThisId = uid; var pwd = collection["pwd"]; var npwd = collection["npwd"]; var npwd2 = collection["nwpd2"]; if (npwd == npwd2) { using (CMSDbEntities db = new CMSDbEntities()) { var user = db.AdminLogins.Find(uid); if (user.pass == pwd) { user.pass = npwd; db.SaveChanges(); ViewBag.Success = "Password er nu ændret."; this.rc.ListAdminUsers(this.rc.Style.ThisPageId); return(this.View(this.rc)); } else { ViewBag.Error = "Nuværende password matcher ikke med det indtastede."; this.rc.ListAdminUsers(this.rc.Style.ThisPageId); return(this.View(this.rc)); } } } else { ViewBag.Error = "De nye passwords stemmer ikke overens med hinanden."; this.rc.ListAdminUsers(this.rc.Style.ThisPageId); return(this.View(this.rc)); } } this.rc.ListAdminUsers(this.rc.Style.ThisPageId); return(this.View(this.rc)); }