public ActionResult CreateKey() { var model = new CreateKeyModel { Items = UserService.FillUserDropDownList(), KeyLimit = 1000 }; return(View(model)); }
public ActionResult CreateKey(CreateKeyModel model) { if (ModelState.IsValid) { return(RedirectToAction("ViewKey", new { id = KeyService.CreateKey(model.SelectedItemId, model.KeyLimit) })); } model.Items = UserService.FillUserDropDownList(); return(View(model)); }
public async Task <int> Create(CreateKeyModel model) { await securityService.ThrowIfNoAccessToProjectWithMinimalRole( HttpContext.User.GetId(), model.ProjectId, ProjectAccountRole.Editor ); return(await translationService.CreateKey(model.ProjectId, model.Key)); }
/// <summary> /// This method will create a new license key, which is the same as GenerateKey in Web API 2. /// </summary> /// <param name="token">Details such as Token and Version.</param> /// <param name="parameters">The parameters that the method needs.</param> /// <remarks>This method may, in rare cases, return null if an error has occurred. /// Null should be seen as an unsuccessful result. /// </remarks> /// <returns>A BasicResult object or null.</returns> /// <example> /// <code language="vb" title="Creating a new key"> /// Private Sub CreateKey() /// Dim parameters = New CreateKeyModel() With { /// .ProductId = 3, /// .F1 = 1, /// .Period = 30 /// } /// Dim auth = "{access token with CreateKey permission and optional product lock}" /// Dim result = Key.CreateKey(token:=auth, parameters:=parameters) /// If (result IsNot Nothing AndAlso result.Result = ResultType.Success) Then /// ' successful /// Console.WriteLine(result.Key) /// End If /// End Sub /// </code> /// </example> public static CreateKeyResult CreateKey(string token, CreateKeyModel parameters) { return(HelperMethods.SendRequestToWebAPI3 <CreateKeyResult>(parameters, "/key/createkey/", token)); }