public ClientEditViewModel() { //CurrentClient = new ClientItemViewModel(); NewClient = new NewClientViewModel(); }
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 ClientEditViewModel() { //CurrentClient = new ClientItemViewModel(); NewClient = new NewClientViewModel(); }