本文整理汇总了C#中Store.AddUser方法的典型用法代码示例。如果您正苦于以下问题:C# Store.AddUser方法的具体用法?C# Store.AddUser怎么用?C# Store.AddUser使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Store
的用法示例。
在下文中一共展示了Store.AddUser方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddUserIsInStore
private void AddUserIsInStore(Users user, Store store)
{
if (!CheckIfUserIsInStore(user, store))
{
store.AddUser(user);
_storeService.SaveOrUpdate(store);
}
}
示例2: Register
public ActionResult Register(RegisterModel model)
{
if (ModelState.IsValid)
{
// Attempt to register the user
try
{
// List<Users> users = userService.GetAll().ToList();
string password = Base.GenearateKey(8);
var status = MembershipCreateStatus.UserRejected;
Membership.CreateUser(model.UserName, password, model.UserName + "@gmail.com", "what is", "yes",
true, null, out status);
MembershipUser user = Membership.GetUser(model.UserName, false);
user.Email = "[email protected]";
Membership.UpdateUser(user);
// Profiles profile = profileProvider.CreateProfile(model.UserName, true);
UserProfileBase profile = UserProfileBase.GetUserProfile(model.UserName);
if (profile != null)
{
profile.FirstName = "jeffrey";
profile.LastName = "Valeroso";
// profile.Address = "Taytay, Rizal";
profile.Gender = "M";
profile.Language = "English";
profile.Position = "Senior Software Developer";
profile.Subscription = "None";
profile.Save();
}
bool check = Roles.RoleExists("MVP");
string[] usernames = { model.UserName };
string[] roles = { "MVP" };
Roles.AddUsersToRoles(usernames, roles);
//add user to role
//System.Web.Security.Roles.AddUserToRole(model.UserName, model.RoleName);
var store = new Store();
store.Address = "Makati City";
store.Active = true;
store.Code = "MC2012";
store.Name = "Greenbelt";
store.DateCreated = DateTime.Now;
store.PermitNo = "1223423";
Users employee = userService.GetUserByUsernameApplicationName(user.UserName, "Exchange");
store.AddUser(employee);
// storeService.SaveOrUpdate(store);
return RedirectToAction("Index", "Home");
}
catch (MembershipCreateUserException e)
{
ModelState.AddModelError("", ErrorCodeToString(e.StatusCode));
}
}
// If we got this far, something failed, redisplay form
return View(model);
}
示例3: ActivateInitialUser
public void ActivateInitialUser()
{
if (!Settings.EnableInitialization) return;
MembershipCreateStatus status;
var userName = Base.GenerateUsername("Jeffrey", "Fuensalida", "Valeroso");
Membership.CreateUser(userName, "[email protected]", "[email protected]", "na", "na", true, null,
out status);
var user = Membership.GetUser(userName, false);
var profile = new RegisterModel
{
FirstName = "Jeffrey",
LastName = "Valeroso",
MiddleName = "Fuensalida",
Address = "Manila, Philippines",
Gender = "M",
Language = "EN",
Position = "Software Developer",
BirthDate = "10/29/1986",
UserName = userName
};
CreateProfile(profile);
//create Admin Role
if (!Roles.RoleExists("Admin"))
{
Roles.CreateRole("Admin");
}
if (!Roles.RoleExists("Super Admin"))
{
Roles.CreateRole("Super Admin");
}
//Add user to Role
if (!Roles.IsUserInRole(userName, "Super Admin"))
{
Roles.AddUserToRole(userName, "Super Admin");
}
//Create new strore
var store = new Store
{
Name = "Main",
Address = "Manila, Philippines",
Active = true,
Code = "000",
CreatedBy = "Admin",
DateCreated = DateTime.Now,
PermitNo = "NA",
TINNo = "NA"
};
_storeService.Create(store);
var employee = _userService.GetUserByUsernameApplicationName(userName,
ConfigManager.Exchange.ApplicationName);
var myStore = _storeService.GetDataById(store.Id);
if (!CheckIfUserIsInStore(employee, myStore))
{
store.AddUser(employee);
_storeService.SaveOrUpdate(myStore);
}
}