public NewClientPage() { InitializeComponent(); BindingContext = new NewClientViewModel(Navigation); NavigationPage.SetHasNavigationBar(this, false); // Hide nav bar }
public NewClient(ProjectManager project_manager) { InitializeComponent(); this._new_client_view_model = new NewClientViewModel(this); this.DataContext = _new_client_view_model; this.ProjectManager = project_manager; }
public async Task <IActionResult> Create([Bind("UserName,Email,Password,ConfirmPassword,IsAdmin,AvatarID")] NewClientViewModel model) { ClientDBExist(model.UserName, model.Email); if (ModelState.IsValid) { var user = new Client { UserName = model.UserName, Email = model.Email, AvatarID = model.AvatarID, EmailConfirmed = true, RegisterTime = DateTime.Now, LockoutEnabled = true }; var result = await UserManager.CreateAsync(user, model.Password); if (result.Succeeded) { if (model.IsAdmin) { var resultAdmin = await UserManager.AddToRoleAsync(user, "Admin"); } TempData["Status"] = "A client named " + model.UserName + " has been created."; TempData["Color"] = "success"; return(RedirectToAction(nameof(Index))); } else { var error = result.Errors.FirstOrDefault(); if (error.Code == "InvalidUserName") { ModelState.AddModelError("UserName", "UserName must contains only letters, digits, - or _ characters."); } else { ModelState.AddModelError("Password", "Password must be 6-16 characters long and have at least 1 letter and 1 digit."); } } } ViewData["AvatarID"] = new SelectList(db.Images.Where(i => i.Category == ImageCategory.Avatars), "ID", "Name", model.AvatarID); return(View(model)); }
public async Task <IActionResult> NewClient(NewClientViewModel clientModel) { if (!ModelState.IsValid) { return(RedirectToAction("EditClient", new { siteId = clientModel.SiteId })); } Guid siteId = siteManager.CurrentSite.Id; if (!string.IsNullOrEmpty(clientModel.SiteId) && clientModel.SiteId.Length == 36) { siteId = new Guid(clientModel.SiteId); } var selectedSite = await siteManager.GetSiteForDataOperations(siteId); var found = await clientsManager.FetchClient(selectedSite.Id.ToString(), clientModel.ClientId); if (found != null) { this.AlertDanger(sr["Client already exists with that client id"], true); return(RedirectToAction("EditClient", new { siteId = selectedSite.Id.ToString(), clientId = found.ClientId })); } var client = new Client(); client.ClientId = clientModel.ClientId; client.ClientName = clientModel.ClientName; client.AccessTokenType = clientModel.AccessTokenType; client.RefreshTokenExpiration = clientModel.RefreshTokenExpiration; client.RefreshTokenUsage = clientModel.RefreshTokenUsage; await clientsManager.CreateClient(selectedSite.Id.ToString(), client); var successFormat = sr["The Client <b>{0}</b> was successfully Created."]; this.AlertSuccess(string.Format(successFormat, client.ClientId), true); return(RedirectToAction("EditClient", new { siteId = selectedSite.Id.ToString(), clientId = client.ClientId })); }
public NewClientPage() { InitializeComponent(); BindingContext = new NewClientViewModel(); }