Ejemplo n.º 1
0
        public async ValueTask <HttpResponseMessage> Audience_CreateV1(string jwt, AudienceV1 model)
        {
            _http.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("bearer", jwt);

            return(await _http.PostAsync("audience/v1",
                                         new StringContent(JsonConvert.SerializeObject(model), Encoding.UTF8, "application/json")));
        }
Ejemplo n.º 2
0
        public IActionResult UpdateV1([FromBody] AudienceV1 model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var audience = uow.Audiences.GetAsNoTracking(QueryExpressionFactory.GetQueryExpression <tbl_Audience>()
                                                         .Where(x => x.Id == model.Id).ToLambda())
                           .SingleOrDefault();

            if (audience == null)
            {
                ModelState.AddModelError(MessageType.AudienceNotFound.ToString(), $"Audience:{model.Id}");
                return(NotFound(ModelState));
            }
            else if (audience.IsDeletable &&
                     audience.IsDeletable != model.IsDeletable)
            {
                ModelState.AddModelError(MessageType.AudienceImmutable.ToString(), $"Audience:{audience.Id}");
                return(BadRequest(ModelState));
            }

            var result = uow.Audiences.Update(map.Map <tbl_Audience>(model));

            uow.Commit();

            return(Ok(map.Map <AudienceV1>(result)));
        }
Ejemplo n.º 3
0
        public async ValueTask <AudienceV1> Audience_CreateV1(AudienceV1 model)
        {
            var response = await Endpoints.Audience_CreateV1(Grant.AccessToken.RawData, model);

            if (response.IsSuccessStatusCode)
            {
                return(await response.Content.ReadAsAsync <AudienceV1>().ConfigureAwait(false));
            }

            throw new HttpRequestException(response.RequestMessage.ToString(),
                                           new Exception(response.ToString()));
        }
Ejemplo n.º 4
0
        public static string ImplicitGrant(IssuerV1 issuer, AudienceV1 audience, UserV1 user, Uri link)
        {
            /*
             * use http://rendera.herokuapp.com/ to test template before format...
             * use https://www.buildmystring.com to format template into string that compiles...
             */

            return("<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\" \"http://www.w3.org/TR/REC-html40/loose.dtd\">" +
                   "<html xmlns=\"http://www.w3.org/1999/xhtml\">" +
                   "  <head>" +
                   "    <!--[if !mso]><!-- -->" +
                   "    <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">" +
                   "    <style>" +
                   "      @font-face { font-family: Open Sans; src: url('http://fonts.googleapis.com/css?f= amily=Open+Sans'); }" +
                   "    </style>" +
                   "    <!--<![endif]-->" +
                   "    <style>" +
                   "      table { color: inherit; }" +
                   "    </style>" +
                   "  </head>" +
                   "  <body style=\"font-size: 31px; font-family: 'Open Sans', 'Helvetica Neue-Light', 'Helvetica Neue Light', 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color:=#404040; padding: 0; width: 100% !important; -webkit-text-size-adjust: 100%; font-weight: 300 !important; margin: 0; -ms-text-size-adjust: 100%;\" marginheight=\"0\" marginwidth=\"0\" id=\"dbx-email-body\">" +
                   "    <div style=\"max-width: 600px !important; padding: 4px;\">" +
                   "      <table cellpadding=\"0\" cellspacing=\"0\" style=\"padding: 0 45px; width: 100% !important; padding-top: 45px;border: 1px solid #F0F0F0; background-color: #FFFFFF;\" border=\"0\" align=\"center\">" +
                   "        <tr>" +
                   "          <td align=\"center\">" +
                   "            <table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" width=\"100%\">" +
                   "              <tr style=\"font-size: 16px; font-weight: 300; color: #404040; font-family: 'Open Sans', 'HelveticaNeue-Light', 'Helvetica Neue Light', 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; line-height: 26px; text-align: left;\">" +
                   "                <td>" +
                   "                  <br>" +
                   "                  <br>Hi " + string.Format("{0} {1}", user.FirstName, user.LastName) + "." +
                   "                  <br>" +
                   "                  <br>The link will log you into the application named " + audience.Name + " automatically." +
                   "                  <br>" +
                   "                  <br><a style=\"border-radius: 4px; font-size: 15px; color: white; text-decoration: none; padding: 14px 7px 14px 7px; width: 210px; max-width: 210px; font-family: 'Open Sans', 'Helvetica Neue', Arial; margin: 0; display: block; background-color:#007ee6; text-align: center;\" href=" + link.AbsoluteUri + ">Login now</a>" +
                   "                  <br>" +
                   "                </td>" +
                   "              <tr>" +
                   "              <tr>" +
                   "                <td height=\"40\"></td>" +
                   "              </tr>" +
                   "            </table>" +
                   "          </td>" +
                   "        </tr>" +
                   "      </table>" +
                   "    </div>" +
                   "  </body>" +
                   "</html>");
        }
Ejemplo n.º 5
0
        public IActionResult CreateV1([FromBody] AudienceV1 model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (uow.Audiences.Get(x => x.IssuerId == model.IssuerId &&
                                  x.Name == model.Name).Any())
            {
                ModelState.AddModelError(MessageType.AudienceAlreadyExists.ToString(), $"Issuer:{model.IssuerId} Audience:{model.Name}");
                return(BadRequest(ModelState));
            }

            var result = uow.Audiences.Create(map.Map <tbl_Audience>(model));

            uow.Commit();

            return(Ok(map.Map <AudienceV1>(result)));
        }