本文整理汇总了C#中GenericRepository.Insert方法的典型用法代码示例。如果您正苦于以下问题:C# GenericRepository.Insert方法的具体用法?C# GenericRepository.Insert怎么用?C# GenericRepository.Insert使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GenericRepository
的用法示例。
在下文中一共展示了GenericRepository.Insert方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Insert
public void Insert()
{
IGenericRepository<SysUser> user = new GenericRepository<SysUser>();
user.Insert(new SysUser()
{
Uid = "test",
Psd = "111111"
});
if (user.Submit() == -1)
Assert.Fail();
}
示例2: Register
public async Task<ActionResult> Register([Bind(Include = "FirstName, GivenName, Email")] RegisterViewModel model)
{
try
{
if (!ModelState.IsValid)
{
return View(model);
}
User user = new User();
UserDetails userDetails = new UserDetails();
//user.Password = model.Password;
user.Email = model.Email;
user.DateCreated = DateTime.UtcNow;
user.DateLastUpdated = DateTime.UtcNow;
user.UserDetails = new UserDetails();
user.UserDetails.FirstName = model.FirstName;
user.UserDetails.GivenName = model.GivenName;
user.UserDetails.Email = model.Email;
user.UserDetails.DateCreated = DateTime.UtcNow;
user.UserDetails.DateLastUpdated = DateTime.UtcNow;
using (var db = NannyContext.Create())
{
GenericRepository<Models.User> repository = new GenericRepository<Models.User>(db);
repository.Insert(user);
repository.Save();
}
EmailHelper emailHelper = new EmailHelper();
emailHelper.Send(user.Id.ToString(), user.UserDetails.FirstName, user.Email);
return View("RegisterSuccess");
}
catch (DataException dex)
{
ModelState.AddModelError("", "Unable to save changes. Try again, and if the problem persists see your system administrator.");
}
return View(model);
}
示例3: AddLanguageSkill
public async Task<ActionResult> AddLanguageSkill([Bind(Include = "IdNanny, IdLanguage, IdLanguageLevel")] LanguageSkill model)
{
try
{
if (!ModelState.IsValid)
{
return PartialView("Profile");
}
model.DateCreated = DateTime.UtcNow;
model.DateLastUpdated = DateTime.UtcNow;
GenericRepository<LanguageSkill> repositoryqLanguageSkill = new GenericRepository<LanguageSkill>(new NannyContext());
repositoryqLanguageSkill.Insert(model);
repositoryqLanguageSkill.Save();
IEnumerable<LanguageSkill> languages = repositoryqLanguageSkill.Get().Where(l => l.IdNanny == model.IdNanny).ToList();
ViewBag.LanguageSkills = languages;
return GetMenu("LanguageSkill");
}
catch (DataException dex)
{
ModelState.AddModelError("", "Unable to save changes. Try again, and if the problem persists see your system administrator.");
}
return View(model);
}