当前位置: 首页>>代码示例>>C#>>正文


C# GenericRepository.Insert方法代码示例

本文整理汇总了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();
        }
开发者ID:taccisum,项目名称:ExerciseSpace,代码行数:12,代码来源:UnitTestCrud.cs

示例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);
        }
开发者ID:NannyWeb,项目名称:Nanny,代码行数:45,代码来源:NannyController.cs

示例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);
        }
开发者ID:NannyWeb,项目名称:Nanny,代码行数:30,代码来源:NannyController.cs


注:本文中的GenericRepository.Insert方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。