本文整理汇总了C#中UserRepository.Insert方法的典型用法代码示例。如果您正苦于以下问题:C# UserRepository.Insert方法的具体用法?C# UserRepository.Insert怎么用?C# UserRepository.Insert使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UserRepository
的用法示例。
在下文中一共展示了UserRepository.Insert方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetMySql
public static void GetMySql()
{
UserRepository rep = new UserRepository(new MySqlDbContext());
rep.Insert(new User { ID = new Guid("12736219-9398-4DBD-A392-BF8C5CCC3635"), Mobile = "01819421877", Password = "NewPassword", Username = "SiamDeath" });
rep.Commit();
var data = rep.Get(new Guid("C1C8D804-0645-4006-B9C8-192EBD944944"));
var collection = rep.GetAll().ToList();
}
示例2: GetSql
public static void GetSql()
{
UserRepository rep = new UserRepository(new WebApiDBContext());
rep.Insert(new User { ID = new Guid("19D40AEC-37B7-4114-A5BF-E4E3B3CFC97A"), Mobile = "01819421877", Password = "NewPassword", Username = "SiamDeath" });
rep.Commit();
var data = rep.Get(new Guid("C1C8D804-0645-4006-B9C8-192EBD944944"));
var collection = rep.GetAll().ToList();
}
示例3: PostUser
/// <summary>
/// ユーザーアカウント新規登録
/// </summary>
/// <param name="newUser">新規ユーザー情報</param>
/// <returns>
/// 成功した場合:登録したユーザー情報
/// 失敗した場合:エラー情報
/// </returns>
public HttpResponseMessage PostUser(User newUser)
{
if (null == newUser)
{
string ErrorMessage = "User information is not specified";
var errorResponse = Request.CreateErrorResponse(HttpStatusCode.BadRequest, ErrorMessage);
return errorResponse;
}
if (false == ModelState.IsValid)
{
var errorInfo = new FeedReaderErrorHandler(ModelState);
var errorResponse = Request.CreateResponse<FeedReaderError>(errorInfo.GetHttpStatusCode(), errorInfo.GetErrorInfo());
return errorResponse;
}
var userDataContext = new UserDataContext();
var userRepository = new UserRepository(userDataContext);
try
{
newUser.SetHashedPassword();
newUser = userRepository.Insert(newUser);
if (null == newUser)
{
if (FeedReaderErrorCode.DuplicateEmail == userRepository.lastError)
{
// TODO: Create Error handler and pass it as error response
var errorResponse = Request.CreateResponse<User>(HttpStatusCode.Ambiguous, newUser);
return errorResponse;
}
}
var response = Request.CreateResponse<User>(HttpStatusCode.Created, newUser);
string uri = Url.Link("DefaultApi", new { id = newUser.Id });
response.Headers.Location = new Uri(uri);
return response;
}
catch (Exception ex)
{
var errorInfo = new FeedReaderErrorHandler(ex);
var response = Request.CreateResponse<FeedReaderError>(errorInfo.GetHttpStatusCode(), errorInfo.GetErrorInfo());
return response;
}
}
示例4: Save_Entity_Test
public static void Save_Entity_Test()
{
IUserRepository repository = new UserRepository(_session);
User operador = new User
{
Login = "Operador Teste",
Name = "Operador Teste",
Password = "Password",
};
repository.Insert(operador);
User operadorBd = repository.GetById(operador.Id);
Assert.AreEqual(operador.Name, operadorBd.Name);
}
示例5: Get_Entity_By_Id
public static void Get_Entity_By_Id()
{
long id = 0;
IUserRepository repository = new UserRepository(_session);
User operadorBd = null;
User operador = new User
{
Login = "Operador Teste Fabrica",
Name = "Operador Teste Fabrica",
Password = "Password Fabrica",
};
repository.Insert(operador);
id = operador.Id;
operadorBd = repository.GetById(id);
Assert.That(operadorBd.GetHashCode(), Is.Not.EqualTo(operador.GetHashCode()));
Assert.That(operadorBd.Id, Is.EqualTo(operador.Id));
}
示例6: InsertUser
public int InsertUser(UserServiceModel user)
{
UserRepository repo = new UserRepository(entities);
User model = new User();
Tuple<string, string> hashSalt = UserUtil.encryptPassword(user.password);
model.FirstName = user.firstname;
model.LastName = user.lastname;
model.MiddleName = user.middlename;
model.Id = 0;
model.UserName = user.username;
model.Password = hashSalt.Item1;
model.Salt = hashSalt.Item2;
model.PasswordExpireDate = DateTime.Now.AddMonths(3);
model.DefectRole = UserUtil.unmapUserRoleToDefect(user.defectRole);
model.ScrumRole = UserUtil.unmapUserRoleToScrum(user.scrumRole);
return repo.Insert(model);
}
示例7: ADDRow
private void ADDRow()
{
using (var db = new CSBCDbContext())
{
try
{
var rep = new UserRepository(db);
var user = new User();
user.HouseID = Convert.ToInt32(lblHouseID.Text); //must be filled in?
user.Name = txtName.Text;
user.UserName = txtUserName.Text;
user.UserType = Convert.ToInt32(radioUserType.SelectedValue);
user.PWord = txtPWord.Text;
user.CreatedUser = Master.UserName;
//user.Roles = GetRoles();
rep.Insert(user);
UserId = user.UserID;
}
catch (Exception ex)
{
Session["ErrorMSG"] = ex.Message;
}
}
}
示例8: Update_Entity_Test
public static void Update_Entity_Test()
{
const string operadorNameAtualizado = "Operador Teste Update";
IUserRepository repository = new UserRepository(_session);
User operador = new User
{
Login = "Operador Teste",
Name = "Operador Teste",
Password = "Password",
};
repository.Insert(operador);
User operadorBd = repository.GetAll().First();
operadorBd.Name = operadorNameAtualizado;
repository.Update(operadorBd);
operadorBd = repository.GetAll().First();
Assert.AreEqual(operadorNameAtualizado, operadorBd.Name);
}