本文整理汇总了C#中TestEntity.SaveChanges方法的典型用法代码示例。如果您正苦于以下问题:C# TestEntity.SaveChanges方法的具体用法?C# TestEntity.SaveChanges怎么用?C# TestEntity.SaveChanges使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TestEntity
的用法示例。
在下文中一共展示了TestEntity.SaveChanges方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateMemberRegister
public JsonResult CreateMemberRegister(tblUserInformation objUser)
{
Dictionary<string, object> res = new Dictionary<string, object>();
try
{
using (var db = new TestEntity())
{
Membership.ApplicationName = "/";
Membership.CreateUser(objUser.Phone.ToString(), objUser.Phone.ToString());
MembershipUser user = Membership.GetUser(objUser.Phone.ToString());
Roles.ApplicationName = "/";
if (!Roles.RoleExists("Customer"))
{
Roles.CreateRole("Customer");
Roles.AddUserToRole(objUser.Phone.ToString(), "Customer");
}
else
{
Roles.AddUserToRole(objUser.Phone.ToString(), "Customer");
}
tblUserInformation objmember = new tblUserInformation();
objmember.idUser = new Guid(user.ProviderUserKey.ToString());
objmember.FirstName = objUser.FirstName;
objmember.LastName = objUser.LastName;
objmember.Phone = objUser.Phone.ToString();
objmember.DOB = objUser.DOB;
objmember.IsActive = true;
objmember.IsCompleted = true;
objmember.IsNotify = false;
objmember.CreatedBy = User.Identity.Name;
objmember.CreatedDatetime = DateTime.Now;
db.tblUserInformations.Add(objmember);
db.SaveChanges();
FormsAuthentication.SetAuthCookie(objUser.Phone.ToString(), false);
Session["Username"] = null;
Session["LanguageId"] = null;
if (Session["Username"] == null)
{
Session["Username"] = objUser.FirstName + " " + objUser.LastName;
}
res["success"] = 1;
}
}
catch (Exception ex)
{
res["error"] = 2;
res["message"] = ex.Message.ToString();
}
return Json(res, JsonRequestBehavior.AllowGet);
}