public bool Update(Guid id, Dictionary <string, object> changes) { using (MovieResShareEntities database = new MovieResShareEntities()) { try { var celeb = database.Basic_Request.FirstOrDefault(p => p.Id == id); foreach (var item in changes) { switch (item.Key) { case "state": celeb.State = (string)item.Value; break; case "note": celeb.Note = (string)item.Value; break; default: break; } } database.SaveChanges(); return(true); } catch (Exception) { return(false); } } }
public bool Delete(Guid id) { using (MovieResShareEntities database = new MovieResShareEntities()) { try { Basic_Movie movie = database.Basic_Movie.FirstOrDefault(p => p.Id == id); database.Basic_Movie.Remove(movie); Step_Movie_Poster poster = database.Step_Movie_Poster.FirstOrDefault(p => p.Movie == id); database.Step_Movie_Poster.Remove(poster); Step_Movie_Rating rating = database.Step_Movie_Rating.FirstOrDefault(p => p.Movie == id); database.Step_Movie_Rating.Remove(rating); var country = database.Step_Movie_Country.Where(p => p.Movie == id); database.Step_Movie_Country.RemoveRange(country); var genre = database.Step_Movie_Genre.Where(p => p.Movie == id); database.Step_Movie_Genre.RemoveRange(genre); var lang = database.Step_Movie_Lang.Where(p => p.Movie == id); database.Step_Movie_Lang.RemoveRange(lang); database.SaveChanges(); return(true); } catch (Exception e) { return(false); } } }
/// <summary> /// 更新Basic_User中的一条数据 /// </summary> /// <param name="id">用户id</param> /// <param name="changes">要更新的值,可以包括多个键值对</param> /// <returns>是否更新成功</returns> public bool Update(Guid id, Dictionary <string, string> changes) { using (MovieResShareEntities database = new MovieResShareEntities()) { try { Basic_User user = database.Basic_User.FirstOrDefault(p => p.Id == id); foreach (var item in changes) { switch (item.Key) { case "password": user.Password = item.Value; break; case "avatar": user.Avatar = item.Value; break; case "cover": user.Cover = item.Value; break; case "limit": user.Limit = bool.Parse(item.Value); break; case "email": user.Email = item.Value; break; case "phone": user.Phone_Number = item.Value; break; default: break; } } database.SaveChanges(); return(true); } catch (Exception) { return(false); } } }
public bool Insert(Basic_Resource_Info info) { using (MovieResShareEntities database = new MovieResShareEntities()) { try { database.Basic_Resource.Add(ToDatabase(info)); database.SaveChanges(); return(true); } catch (Exception e) { return(false); } } }
public bool Delete(Guid id) { using (MovieResShareEntities database = new MovieResShareEntities()) { try { var resource = database.Basic_Resource.FirstOrDefault(p => p.Id == id); database.Basic_Resource.Remove(resource); database.SaveChanges(); return(true); } catch (Exception) { return(false); } } }
//public bool Update(Guid id, Dictionary<string, object> changes) //{ // using (MovieResShareEntities database = new MovieResShareEntities()) // { // try // { // var celeb = database.Basic_Movie_Visit.FirstOrDefault(p => p.Id == id); // foreach (var item in changes) // { // switch (item.Key) // { // case "state": // celeb.State = (string)item.Value; // break; // case "note": // celeb.Note = (string)item.Value; // break; // default: break; // } // } // database.SaveChanges(); // return true; // } // catch (Exception) // { // return false; // } // } //} public bool Delete(Guid id) { using (MovieResShareEntities database = new MovieResShareEntities()) { try { var sigin = database.Basic_User_Signin.FirstOrDefault(p => p.Id == id); database.Basic_User_Signin.Remove(sigin); database.SaveChanges(); return(true); } catch (Exception) { return(false); } } }
public bool Update(Guid id, Dictionary <string, object> changes) { using (MovieResShareEntities database = new MovieResShareEntities()) { try { var celeb = database.Basic_Collection.FirstOrDefault(p => p.Id == id); foreach (var item in changes) { switch (item.Key) { case "title": celeb.Title = (string)item.Value; break; case "content": celeb.Content = (string)item.Value; break; case "summary": celeb.Summary = (string)item.Value; break; case "cover": celeb.Cover = (string)item.Value; break; case "altertime": celeb.Alter_Time = (DateTime)item.Value; break; default: break; } } database.SaveChanges(); return(true); } catch (Exception) { return(false); } } }
public bool Delete(Guid id) { using (MovieResShareEntities database = new MovieResShareEntities()) { try { Basic_Celebrity celeb = database.Basic_Celebrity.FirstOrDefault(p => p.Id == id); Step_Celeb_Avatar avatar = database.Step_Celeb_Avatar.FirstOrDefault(p => p.Celeb == id); database.Basic_Celebrity.Remove(celeb); database.Step_Celeb_Avatar.Remove(avatar); database.SaveChanges(); return(true); } catch (Exception e) { return(false); } } }
public bool Update(Guid id, Dictionary <string, object> changes) { using (MovieResShareEntities database = new MovieResShareEntities()) { try { var movie = database.Basic_Movie.FirstOrDefault(p => p.Id == id); foreach (var item in changes) { switch (item.Key) { case "title": movie.Title = (string)item.Value; break; case "titleen": movie.Title_En = (string)item.Value; break; case "aka": movie.Aka = (string)item.Value; break; case "year": movie.Year = (short)item.Value; break; case "website": movie.Website = (string)item.Value; break; case "currentseason": movie.Current_Season = (short)item.Value; break; case "seasoncount": movie.Season_Count = (short)item.Value; break; case "episodecount": movie.Episode_Count = (int)item.Value; break; case "pubdate": movie.Pubdate = (string)item.Value; break; case "duration": movie.Duration = (string)item.Value; break; case "douban": movie.Douban = (string)item.Value; break; case "imdb": movie.IMDb = (string)item.Value; break; case "summary": movie.Summary = (string)item.Value; break; case "collectcount": movie.Summary = (string)item.Value; break; case "altertime": movie.Alter_Time = (DateTime)item.Value; break; case "country": var removecountry = database.Step_Movie_Country.Where(p => p.Movie == id); foreach (var item1 in removecountry) { database.Step_Movie_Country.Remove(item1); } foreach (var item2 in (List <Step_Movie_Country_Info>)item.Value) { movie.Step_Movie_Country.Add(Step_Movie_Country_DAL.ToDatabase(item2)); } break; case "genre": var removegenre = database.Step_Movie_Genre.Where(p => p.Movie == id); foreach (var item1 in removegenre) { database.Step_Movie_Genre.Remove(item1); } foreach (var item2 in (List <Step_Movie_Genre_Info>)item.Value) { movie.Step_Movie_Genre.Add(Step_Movie_Genre_DAL.ToDatabase(item2)); } break; case "lang": var removelang = database.Step_Movie_Lang.Where(p => p.Movie == id); foreach (var item1 in removelang) { database.Step_Movie_Lang.Remove(item1); } foreach (var item2 in (List <Step_Movie_Lang_Info>)item.Value) { movie.Step_Movie_Lang.Add(Step_Movie_Lang_DAL.ToDatabase(item2)); } break; case "poster": movie.Step_Movie_Poster.FirstOrDefault().Large = ((Step_Movie_Poster_Info)item.Value).Large; movie.Step_Movie_Poster.FirstOrDefault().Small = ((Step_Movie_Poster_Info)item.Value).Small; movie.Step_Movie_Poster.FirstOrDefault().Medium = ((Step_Movie_Poster_Info)item.Value).Medium; break; case "rating": movie.Step_Movie_Rating.FirstOrDefault().Rated_Num = ((Step_Movie_Rating_Info)item.Value).Rated_Num; movie.Step_Movie_Rating.FirstOrDefault().Score = ((Step_Movie_Rating_Info)item.Value).Score; movie.Step_Movie_Rating.FirstOrDefault().Star1 = ((Step_Movie_Rating_Info)item.Value).Star1; movie.Step_Movie_Rating.FirstOrDefault().Star2 = ((Step_Movie_Rating_Info)item.Value).Star2; movie.Step_Movie_Rating.FirstOrDefault().Star3 = ((Step_Movie_Rating_Info)item.Value).Star3; movie.Step_Movie_Rating.FirstOrDefault().Star4 = ((Step_Movie_Rating_Info)item.Value).Star4; movie.Step_Movie_Rating.FirstOrDefault().Star5 = ((Step_Movie_Rating_Info)item.Value).Star5; break; default: break; } } database.SaveChanges(); return(true); } catch (Exception e) { return(false); } } }
public bool Update(Guid id, Dictionary <string, object> changes) { using (MovieResShareEntities database = new MovieResShareEntities()) { try { var celeb = database.Basic_Celebrity.FirstOrDefault(p => p.Id == id); foreach (var item in changes) { switch (item.Key) { case "name": celeb.Name = (string)item.Value; break; case "nameen": celeb.Name_En = (string)item.Value; break; case "aka": celeb.Aka = (string)item.Value; break; case "akaen": celeb.Aka_En = (string)item.Value; break; case "gender": celeb.Gender = (bool)item.Value; break; case "profession": celeb.Profession = (string)item.Value; break; case "birthdate": celeb.Birth_Date = (string)item.Value; break; case "deathdate": celeb.Death_Date = (string)item.Value; break; case "bornplace": celeb.Profession = (string)item.Value; break; case "family": celeb.Family = (string)item.Value; break; case "douban": celeb.Douban = (string)item.Value; break; case "imdb": celeb.IMDb = (string)item.Value; break; case "summary": celeb.Summary = (string)item.Value; break; case "altertime": celeb.Alter_Time = (DateTime)item.Value; break; case "avatar": celeb.Step_Celeb_Avatar.FirstOrDefault().Large = ((Step_Celeb_Avatar_Info)item.Value).Large; celeb.Step_Celeb_Avatar.FirstOrDefault().Small = ((Step_Celeb_Avatar_Info)item.Value).Small; celeb.Step_Celeb_Avatar.FirstOrDefault().Medium = ((Step_Celeb_Avatar_Info)item.Value).Medium; break; default: break; } } database.SaveChanges(); return(true); } catch (Exception e) { return(false); } } }