public static bool Insert(Basic_User_Info info) { Basic_User_DAL _Basic_User = new Basic_User_DAL(); if (info.Id == Guid.Empty || info.Account.IsBlank() || info.Password.IsBlank()) { return(false); } return(_Basic_User.Insert(info)); }
/// <summary> /// Model类Basic_User_Info转化为数据库表Basic_User /// </summary> /// <param name="info">要转化的Model类Basic_User_Info</param> /// <returns>转化后的数据库表Basic_User</returns> private Basic_User ToDatabase(Basic_User_Info info) { Basic_User user = new Basic_User(); user.Id = info.Id; user.Account = info.Account; user.Password = info.Password; user.Avatar = info.Avatar; user.Cover = info.Cover; user.Limit = info.Limit; user.Email = info.Email; user.Phone_Number = info.Phone_Number; return(user); }
/// <summary> /// 数据库表Basic_User转化为Model类Basic_User_Info /// </summary> /// <param name="user">要转化的Model类Basic_User</param> /// <returns>转化后的数据库表Basic_User_Info</returns> private Basic_User_Info ToModel(Basic_User user) { Basic_User_Info info = new Basic_User_Info(); info.Id = user.Id; info.Account = user.Account; info.Password = user.Password; info.Avatar = user.Avatar; info.Cover = user.Cover; info.Limit = (bool)user.Limit; info.Email = user.Email; info.Phone_Number = user.Phone_Number; return(info); }
/// <summary> /// 向Basic_User中插入一条数据 /// </summary> /// <param name="info"></param> /// <returns>是否插入成功</returns> public bool Insert(Basic_User_Info info) { using (MovieResShareEntities database = new MovieResShareEntities()) { try { database.Basic_User.Add(ToDatabase(info)); database.SaveChanges(); return(true); } catch (Exception e) { return(false); } } }