public IActionResult Create(AppInputModel app) { if (ModelState.IsValid) { var createdApp = _appService.CreateApi(app); _appService.Create(createdApp); return(RedirectToAction(nameof(Index))); } return(View(app)); }
private void VendorList_EditEnding(object?sender, DataGridRowEditEndingEventArgs e) { var vendorEditedDto = e.Row.DataContext as VendorDto; if (vendorEditedDto == null || e.EditAction != DataGridEditAction.Commit) { return; } if (e.Row.IsNewItem) { _vendorAppService.Create(vendorEditedDto); } else { _vendorAppService.Update(vendorEditedDto, vendorEditedDto.Id); } }
public async Task <ActionResult> New(AppModel model) { if (!model.IsValidForNew()) { model.Msg = "bir sorun oluştu..."; return(View(model)); } model.CreatedBy = User.Identity.GetUserId(); model.Email = User.Identity.GetUserEmail(); var appId = await _appService.Create(model); if (appId == null) { model.Msg = "bir sorun oluştu..."; return(View(model)); } return(Redirect("/app/detail/" + appId)); }
private void GraphicCardList_EditEnding(object?sender, DataGridRowEditEndingEventArgs e) { var graphicCardEditedDto = e.Row.DataContext as GraphicCardDto; if (graphicCardEditedDto == null || e.EditAction != DataGridEditAction.Commit) { return; } if (VendorList.All(x => graphicCardEditedDto.VendorName != x.Name)) { MessageBox.Show("Incorrect Vendor Name!", "Graphic Card Compare Error"); return; } if (e.Row.IsNewItem) { _graphicCardAppService.Create(graphicCardEditedDto); } else { _graphicCardAppService.Update(graphicCardEditedDto, graphicCardEditedDto.Id); } }
public ActionResult Register() { var applicantInputModel = _applicantService.Create(); return(View(applicantInputModel)); }
// GET api/<controller>/5 public async Task <HttpResponseMessage> Get(string id) { HttpResponseMessage result = new HttpResponseMessage(); List <KeyValuePair <string, string> > queryString = Request.GetQueryNameValuePairs().ToList(); string objectId = queryString.FirstOrDefault(q => q.Key == "objectId").Value; string email = queryString.FirstOrDefault(q => q.Key == "email").Value; string firstName = queryString.FirstOrDefault(q => q.Key == "firstName").Value; string lastName = queryString.FirstOrDefault(q => q.Key == "lastName").Value; if (string.IsNullOrEmpty(id) || string.IsNullOrEmpty(objectId) || string.IsNullOrEmpty(email) || string.IsNullOrEmpty(firstName) || string.IsNullOrEmpty(lastName)) { result.StatusCode = HttpStatusCode.BadRequest; result.Content = new StringContent("Please pass an id, objectId, email, firstName, and lastName on the querystring"); } else { string partitionKey = id.Substring(0, 1).ToLower(); OrganizationSubscription subscription = await _registrationService.GetOrganizationSubscription(partitionKey, id); if (subscription == null) { // Create Azure AD Application Registration for the Organization Guid uniqueId = Guid.NewGuid(); Application application = new Application(); application.DisplayName = $"AAD - {id} Client Application"; application.IdentifierUris = new List <string>(); application.IdentifierUris.Add($"https://{ConfigurationManager.AppSettings["TENANT"]}/{uniqueId}"); application.PasswordCredentials = new List <PasswordCredential>(); var startDate = DateTime.Now; Byte[] bytes = new Byte[32]; using (var rand = System.Security.Cryptography.RandomNumberGenerator.Create()) { rand.GetBytes(bytes); } string clientSecret = Convert.ToBase64String(bytes); application.PasswordCredentials.Add(new PasswordCredential() { CustomKeyIdentifier = null, StartDate = startDate, EndDate = new DateTime(2299, 12, 31, 5, 0, 0, 0), KeyId = Guid.NewGuid(), Value = clientSecret }); application.RequiredResourceAccess = new List <RequiredResourceAccess>(); RequiredResourceAccess graphResourceAccess = new RequiredResourceAccess() { ResourceAccess = new List <ResourceAccess>(), ResourceAppId = "00000003-0000-0000-c000-000000000000" }; graphResourceAccess.ResourceAccess.Add(new ResourceAccess() { Id = new Guid("37f7f235-527c-4136-accd-4a02d197296e"), Type = "Scope" }); graphResourceAccess.ResourceAccess.Add(new ResourceAccess() { Id = new Guid("7427e0e9-2fba-42fe-b0c0-848c9e6a8182"), Type = "Scope" }); RequiredResourceAccess apimResourceAccess = new RequiredResourceAccess() { ResourceAccess = new List <ResourceAccess>(), ResourceAppId = "30fe3279-fbb4-4a13-b1f8-7c5f2ea9e6df" }; apimResourceAccess.ResourceAccess.Add(new ResourceAccess() { Id = new Guid("f9bcce35-145a-4199-bf1b-948467774061"), Type = "Role" }); application.RequiredResourceAccess.Add(graphResourceAccess); application.RequiredResourceAccess.Add(apimResourceAccess); application.ReplyUrls = new List <string>(); application.ReplyUrls.Add($"msapp://{uniqueId}"); string clientId = await _appService.Create(application); // Create APIM subscription key for the organization Guid primaryKey = Guid.NewGuid(); Guid secondaryKey = Guid.NewGuid(); APIMSubscription apimSubscription = await _subscriptionService.CreateOrgSubscription($"APIM {id} Subscription", "/products/starter", primaryKey, secondaryKey, $"{id}@{_orgEmailDomain}", id, id); // Store subscription information in Table Storage OrganizationSubscription organizationSubscription = new OrganizationSubscription() { Organization = id, PrimarySubscriptionKey = apimSubscription.properties.primaryKey, SecondarySubscriptionKey = apimSubscription.properties.secondaryKey, Scope = apimSubscription.properties.scope, ClientId = clientId, ClientSecret = clientSecret }; OrganizationEntity organizationEntity = new OrganizationEntity(organizationSubscription); await _registrationService.CreateOrganizationSubscription(organizationEntity); // Create pending APIM subscription for the user APIMSubscription apimUserSubscription = await _subscriptionService.CreateSubscription($"APIM {id} Subscription", "/products/starter", Guid.NewGuid(), Guid.NewGuid(), objectId, email, firstName, lastName); // No user subscriptions have been approved yet so return masked values ResponseContent responseContent = new ResponseContent { version = "1.0.0", status = (int)HttpStatusCode.OK, organization = id, primarySubscriptionKey = MASKED_VALUE, secondarySubscriptionKey = MASKED_VALUE, clientId = MASKED_VALUE, clientSecret = MASKED_VALUE }; result.StatusCode = HttpStatusCode.OK; result.Content = new StringContent(JsonConvert.SerializeObject(responseContent), Encoding.UTF8, "application/json"); } else { string state = string.Empty; bool userHasSubscription = false; UserSubscriptions userSubscriptions = await _subscriptionService.GetUserSubscriptions(email); if (userSubscriptions != null && userSubscriptions.count > 0) { foreach (UserSubscription userSubscription in userSubscriptions.value) { if (userSubscription.properties.scope.EndsWith(subscription.Scope, StringComparison.InvariantCultureIgnoreCase)) { state = userSubscription.properties.state; userHasSubscription = true; break; } } } if (!userHasSubscription) { APIMSubscription apimSubscription = await _subscriptionService.CreateSubscription($"APIM {id} Subscription", "/products/starter", Guid.NewGuid(), Guid.NewGuid(), objectId, email, firstName, lastName); state = apimSubscription.properties.state; } ResponseContent responseContent = null; if (state == "active") // User has an approved subscription - share the organization values { responseContent = new ResponseContent { version = "1.0.0", status = (int)HttpStatusCode.OK, organization = id, primarySubscriptionKey = subscription.PrimarySubscriptionKey, secondarySubscriptionKey = subscription.SecondarySubscriptionKey, clientId = subscription.ClientId, clientSecret = subscription.ClientSecret }; } else // User has a pending subscription - return masked values { responseContent = new ResponseContent { version = "1.0.0", status = (int)HttpStatusCode.OK, organization = id, primarySubscriptionKey = MASKED_VALUE, secondarySubscriptionKey = MASKED_VALUE, clientId = MASKED_VALUE, clientSecret = MASKED_VALUE }; } result.StatusCode = HttpStatusCode.OK; result.Content = new StringContent(JsonConvert.SerializeObject(responseContent), Encoding.UTF8, "application/json"); } } return(result); }