public async Task <IActionResult> CreateImplicitApplicationAsync([FromBody] CreateApplicationViewModel applicationViewModel)
        {
            Client client = new Client
            {
                ClientId                    = Guid.NewGuid().ToString().Replace("-", ""),
                ClientName                  = applicationViewModel.ApplicationName,
                AllowedGrantTypes           = GrantTypes.Implicit,
                AllowAccessTokensViaBrowser = true,
                ClientUri                   = applicationViewModel.HomepageURL,
                RedirectUris                = { $"{applicationViewModel.AuthorizationCallbackURL}/swagger/oauth2-redirect.html" },
                PostLogoutRedirectUris      = { $"{applicationViewModel.HomepageURL}/swagger/" },

                AllowedScopes =
                {
                    "orders"
                }
            };

            IdentityServer4.EntityFramework.Entities.Client clientEntity = client.ToEntity();
            clientEntity.Description = applicationViewModel.ApplicationDescription;

            _context.Clients.Add(clientEntity);

            await _context.SaveChangesAsync();

            return(CreatedAtAction(nameof(GetAsync), new { id = clientEntity.Id }, null));
        }
示例#2
0
        public async Task <IActionResult> Create()
        {
            var model = new CreateApplicationViewModel();
            await model.LoadTransportAsync(_ctx);

            return(View(model));
        }
        public bool saveApplicationInDB(CreateApplicationViewModel app)
        {
            bool        result = false;
            Application app_   = new Application()
            {
                applicationName        = app.applicationName,
                applicationDescription = app.applicationDescription,
                applicationStatus      = app.applicationStatus.ToString()
            };

            using (ErrorLoggerDBContext context = new ErrorLoggerDBContext())
            {
                try
                {
                    var application = context.Applications.Where(x => x.applicationName.Equals(app.applicationName)).Any();
                    if (!application)
                    {
                        context.Applications.Add(app_);
                        context.SaveChanges();
                        result = true;
                    }
                }
                catch
                {
                    Log.Error("Function: saveApplicationInDB CustomizeDeveloperMessage: Not able to save Application in DB. Database Error.");
                    throw new Exception("CustomizeDeveloperMessage: Not able to save Application in DB. Database Error. ");
                }
            }

            return(result);
        }
示例#4
0
        public async Task <IActionResult> ApplyToCourseWork([FromBody] CreateApplicationViewModel createApplicationViewModel, long courseWorkId)
        {
            var userId = Request.GetUserId();
            var id     = await _courseWorksService
                         .ApplyToCourseWorkAsync(userId, courseWorkId, createApplicationViewModel)
                         .ConfigureAwait(false);

            return(Ok(id));
        }
示例#5
0
        public async Task <IActionResult> Create(CreateApplicationViewModel model, [FromServices] ICryptoServices crypto)
        {
            if (ModelState.IsValid)
            {
                var app = await model.SaveChangesAsync(_ctx, crypto);

                return(RedirectToAction(nameof(Details), new { id = app.Id }));
            }

            await model.LoadTransportAsync(_ctx);

            return(View(model));
        }
        public ActionResult CreateApplication(CreateApplicationViewModel app)
        {
            if (ModelState.IsValid)
            {
                int dateId = WebSettings.getCurrentDate();

                SinisianDatabase sinDb = srch.FindInSinisian(app.FirstName, app.MiddleName, app.LastName);

                string referenceNum = ReferenceFactory.GenerateReference(app.FirstName + app.MiddleName + app.LastName);

                if (sinDb == null)
                {
                    TempData["errorMsg"] = "Sorry we cannot find your identity.";
                    return(RedirectToAction("CreateApplication", app));
                }

                int count = ent.Applications.Where(m => m.SinId == sinDb.SinId && m.DSetIdApplied == dateId).Count();

                if (count >= 1)
                {
                    TempData["errorMsg"] = "You already have an application. You can check your status from the \"Application Status\" in the navbar.";
                    return(RedirectToAction("CreateApplication"));
                }

                /**
                 * isa, if officer na siya hindi na siya pwede pang mag aaply pa para maging officer
                 */

                Application application = new Application()
                {
                    ATypeId       = int.Parse(app.ApplicationType),
                    ASTypId       = ent.ApplicationStatusTypes.Where(m => m.Name.ToLower() == "queue").Select(m => m.ASTypId).FirstOrDefault(),
                    DSetIdApplied = dateId,
                    RerenceNum    = referenceNum,
                    SinId         = sinDb.SinId,
                };

                ent.Applications.Add(application);
                ent.SaveChanges();

                Mailer.SendEmail(new IdentityMessage()
                {
                    Subject = "Application Reference Number", Body = "<b>" + referenceNum + "</b> is your reference number to your application.<br><br>Please click this link to check application status.<br><br><br><br><b>Sincerely,</b><br>Flores De Mayo President.<br><br><br><br>If you have any concern please send a feedback to us at <a href=\"\">this link.</a>", Destination = app.Email
                });
            }
            else
            {
            }

            return(RedirectToAction("CreateApplication"));
        }
        public async Task <IActionResult> CreateOAuthApplicationAsync([FromBody] CreateApplicationViewModel applicationViewModel)
        {
            Client client = new Client
            {
                ClientId      = Guid.NewGuid().ToString().Replace("-", ""),
                ClientName    = applicationViewModel.ApplicationName,
                ClientSecrets = new List <Secret>
                {
                    new Secret("secret".Sha256())
                },
                ClientUri                        = $"{applicationViewModel.HomepageURL}", //public uri of the client
                AllowedGrantTypes                = GrantTypes.CodeAndClientCredentials,   // or GrantTypes.Code
                AllowAccessTokensViaBrowser      = false,
                RequireConsent                   = false,
                AllowOfflineAccess               = true,
                AlwaysIncludeUserClaimsInIdToken = true,
                RedirectUris                     = new List <string>
                {
                    $"{applicationViewModel.AuthorizationCallbackURL}/signin-oidc"
                },
                PostLogoutRedirectUris = new List <string>
                {
                    $"{applicationViewModel.HomepageURL}/signout-callback-oidc"
                },
                AllowedScopes = new List <string>
                {
                    IdentityServerConstants.StandardScopes.OpenId,
                    IdentityServerConstants.StandardScopes.Profile,
                    IdentityServerConstants.StandardScopes.OfflineAccess,
                    "orders",
                    "basket",
                    "locations",
                    "marketing",
                    "webshoppingagg",
                    "orders.signalrhub",
                    "webhooks"
                },
                AccessTokenLifetime   = 60 * 60 * 2, // 2 hours
                IdentityTokenLifetime = 60 * 60 * 2  // 2 hours
            };

            IdentityServer4.EntityFramework.Entities.Client clientEntity = client.ToEntity();
            clientEntity.Description = applicationViewModel.ApplicationDescription;

            _context.Clients.Add(clientEntity);

            await _context.SaveChangesAsync();

            return(CreatedAtAction(nameof(GetAsync), new { id = clientEntity.Id }, null));
        }
        public async Task <IActionResult> Create(CreateApplicationViewModel model)
        {
            var application = new IdentityServiceApplication
            {
                Name     = model.Name,
                ClientId = Guid.NewGuid().ToString()
            };

            await _applicationManager.CreateAsync(application);

            await _applicationManager.AddScopeAsync(application, OpenIdConnectScope.OpenId);

            await _applicationManager.AddScopeAsync(application, "offline_access");

            return(RedirectToAction(nameof(CreateScope), new { id = application.Id }));
        }
示例#9
0
        public async Task <ActionResult> Create(Guid?id, CreateApplicationViewModel request)
        {
            if (!id.HasValue)
            {
                return(HttpNotFound());
            }

            var defaultStatus = _db.ApplicationStatus.FirstOrDefault(s => s.Description == "Submitted");
            var application   = request.ToApplication(id.Value, defaultStatus.Id);

            _db.Applications.Attach(application);
            _db.Entry(application).State = EntityState.Added;
            await _db.SaveChangesAsync();

            return(RedirectToAction("Student", new { id = id }));
        }
示例#10
0
        public ActionResult createApplication(CreateApplicationViewModel application)
        {
            if (ModelState.IsValid)
            {
                MvcApplication.logger.log("Controller: Admin Action: Create Application Method: POST Info: Modal State is Valid", 1);
                ApplicationDataHandler dataSource = new ApplicationDataHandler();
                if (dataSource.saveApplicationInDB(application))
                {
                    return(RedirectToAction("Index", "Admin", null));
                }
                else
                {
                    MvcApplication.logger.log("Controller: Admin Action: Create Application Method: POST Error:  Application already exist.", 3);
                    throw new Exception("CustomizeDeveloperMessage: Not able to save Application in DB. Check if, Application already exist.");
                }
            }

            return(View(application));
        }
示例#11
0
        public async Task <IActionResult> Create(CreateApplicationViewModel request)
        {
            if (!ModelState.IsValid)
            {
                return(Json(ModelState.Values.SelectMany(entry => entry.Errors)));
            }

            var result = await _applicationService.Create(new CreateApplicationDto()
            {
                Email    = request.Email,
                Phone    = request.Phone,
                AdvertId = request.AdvertId
            });

            if (!result.Ok)
            {
                return(Json(result.Errors));
            }

            return(RedirectToAction("Index", "Home"));
        }