public override string delete_badge(int id) { string msg = ""; using (var context = new PHCEntities()) { try { Badge bdg = new Badge(); bdg = context.Badges.Where(p => p.BId == id).SingleOrDefault(); if (bdg != null) { context.DeleteObject(bdg); } List <Challenge> profile = context.Challenges.Where(m => m.BadgeID == id).ToList(); if (profile != null) { foreach (Challenge n in profile) { context.DeleteObject(n); } } List <PetEarnBadge> pearn = context.PetEarnBadges.Where(m => m.BID == id).ToList(); if (pearn != null) { foreach (PetEarnBadge n in pearn) { context.DeleteObject(n); } } context.SaveChanges(); msg = "success"; } catch (Exception ex) { msg = ex.Message; } } return(msg); }
public override string deleteuser(int id) { string msg = ""; using (var context = new PHCEntities()) { try { User usr = context.Users.Where(p => p.UID == id).SingleOrDefault(); context.DeleteObject(usr); List <PetEarnBadge> pern = context.PetEarnBadges.Where(k => k.UID == id).ToList(); if (pern != null) { foreach (PetEarnBadge c in pern) { context.DeleteObject(c); } } List <PetProfile> profile = context.PetProfiles.Where(m => m.UID == id).ToList(); if (profile != null) { foreach (PetProfile n in profile) { context.DeleteObject(n); } } context.SaveChanges(); msg = "success"; } catch (Exception ex) { msg = ex.Message; } return(msg); } }
public override string delete_challenge(int id) { string msg = ""; using (var context = new PHCEntities()) { try { Challenge chl = new Challenge(); chl = context.Challenges.Where(p => p.CHID == id).SingleOrDefault(); if (chl != null) { context.DeleteObject(chl); } List <PetEarnBadge> pearn = context.PetEarnBadges.Where(m => m.CID == id).ToList(); if (pearn != null) { foreach (PetEarnBadge n in pearn) { context.DeleteObject(n); } } msg = "success"; context.SaveChanges(); } catch (Exception ex) { msg = ex.Message; } } return(msg); }
public override string delete_wall(int id) { string msg = ""; using (var context = new PHCEntities()) { try { Wallpaper wall = new Wallpaper(); wall = context.Wallpapers.Where(p => p.WID == id).SingleOrDefault(); if (wall != null) { context.DeleteObject(wall); context.SaveChanges(); msg = "success"; } } catch (Exception ex) { msg = ex.Message; } } return(msg); }