Ejemplo n.º 1
0
        public async Task <ActionResult <PartnerInvitationResponseInfo> > Get()
        {
            try
            {
                var jwtPayloadInfo    = this.GetJwtPayloadInfo();
                var partnerInvitation = await _bl.GetPartnerInvitations_byExtRefIdAsync(jwtPayloadInfo.ExtReferenceId);

                if (partnerInvitation == null)
                {
                    return(this.ApiErrorMessage404NotFound($"No data found for UserId {jwtPayloadInfo.ExtReferenceId}"));
                }

                var response = new PartnerInvitationResponseInfo
                {
                    DateOfBirth      = partnerInvitation.DateOfBirth,
                    FirstName        = partnerInvitation.FirstName,
                    InvitationId     = partnerInvitation.InvitationId,
                    InvitationStatus = EnumMapper.From(partnerInvitation.InvitationStatus),
                    LastName         = partnerInvitation.LastName,
                    MobilePhone      = partnerInvitation.MobilePhone,
                    TypeOfGender     = EnumMapper.From(partnerInvitation.TypeOfGender),
                };

                return(Json(response));
            }
            catch (Exception ex)
            {
                HttpContext.Items.Add("ex", ex); //For instrumentation
                return(StatusCode(StatusCodes.Status500InternalServerError));
            }
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> Post([FromBody] PartnerInvitationRequestInfo request)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(this.ApiErrorMessage400BadRequest(ModelState));
                }

                var jwtPayloadInfo = this.GetJwtPayloadInfo();
                var userProfileId  = await _bl.GetCachedUserId_byExternalReferenceIdAsync(jwtPayloadInfo.ExtReferenceId);

                if (userProfileId == null)
                {
                    return(this.ApiErrorMessage400BadRequestUserIdInTokenNotFound(jwtPayloadInfo.ExtReferenceId));
                }

                var bl_partnerInvitation = new BL_PartnerInvitation
                {
                    DateOfBirth     = request.DateOfBirth,
                    FirstName       = request.FirstName,
                    InvitedByUserId = userProfileId,
                    LastName        = request.LastName,
                    MobilePhone     = request.MobilePhone,
                    TypeOfGender    = EnumMapper.From(request.TypeOfGender),
                };

                await _bl.SetPartnerInvitationsAsync(bl_partnerInvitation);

                return(this.ApiPostMessage204NotContent());
            }
            catch (BusinessLogicException ex)
            {
                HttpContext.Items.Add("ex", ex); //For instrumentation
                return(this.ApiErrorMessage400BadRequest(ex));
            }
            catch (Exception ex)
            {
                HttpContext.Items.Add("ex", ex); //For instrumentation
                return(this.ApiErrorMessage400BadRequest(ex));
            }
        }
Ejemplo n.º 3
0
        public async Task <IActionResult> Post([FromBody] AppCenterRequestInfo request)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(this.ApiErrorMessage400BadRequest(ModelState));
                }

                var jwtPayloadInfo = this.GetJwtPayloadInfo();
                var userProfileId  = await _bl.GetCachedUserId_byExternalReferenceIdAsync(jwtPayloadInfo.ExtReferenceId);

                if (userProfileId == null)
                {
                    return(this.ApiErrorMessage400BadRequestUserIdInTokenNotFound(jwtPayloadInfo.ExtReferenceId));
                }

                var bl_dto = new BL_AppCenterDetails
                {
                    DeviceId      = request.DeviceId,
                    DTUpdated     = DateTimeOffset.MinValue,
                    TypeOfOs      = EnumMapper.From(request.TypeDeviceOs),
                    UserprofileId = userProfileId
                };

                await _bl.SetAppCenterDetailsAsync(bl_dto);

                return(this.ApiPutMessage204NotContent());
            }
            catch (BusinessLogicException ex)
            {
                HttpContext.Items.Add("ex", ex); //For instrumentation
                return(this.ApiErrorMessage400BadRequest(ex));
            }
            catch (Exception ex)
            {
                HttpContext.Items.Add("ex", ex); //For instrumentation
                return(StatusCode(StatusCodes.Status500InternalServerError));
            }
        }
Ejemplo n.º 4
0
        public async Task <IActionResult> Get([FromQuery] int nrOfRecentTransactions = 3)
        {
            try
            {
                var jwtPayloadInfo = this.GetJwtPayloadInfo();
                var userProfileId  = await _bl.GetCachedUserId_byExternalReferenceIdAsync(jwtPayloadInfo.ExtReferenceId);

                if (userProfileId == null)
                {
                    return(this.ApiErrorMessage400BadRequestUserIdInTokenNotFound(jwtPayloadInfo.ExtReferenceId));
                }

                var bl_ebaResponse = await _bl.GetEbaTransactions_ByUserIdAsync(userProfileId);

                var response = new EbaResponseInfo
                {
                    EbaPointOptions    = getEbaPointOptions(),
                    EbaPointsBalance   = bl_ebaResponse.EbaPointsBalance,
                    EbaPointsDeposited = bl_ebaResponse.EbaPointsDeposited,
                    RecentTransactions = getRecentTransactions()
                };

                List <EbaTransaction> getRecentTransactions()
                {
                    var r = new List <EbaTransaction>();

                    foreach (var item in bl_ebaResponse.RecentTransactions)
                    {
                        r.Add(new EbaTransaction {
                            Comment = item.Comment, FirstName = item.FirstName, Id = item.Id, Point = item.Point, Posted = item.Posted, TypeOfTransaction = EnumMapper.From(item.TypeOfTransaction)
                        });
                    }
                    return(r);
                }

                List <EbaPointOption> getEbaPointOptions()
                {
                    var r = new List <EbaPointOption>();

                    foreach (var item in bl_ebaResponse.EbaPointOptions)
                    {
                        r.Add(new EbaPointOption {
                            Text = item.Text, Value = item.PointValue
                        });
                    }

                    return(r);
                }


                return(Json(response));
            }
            catch (BusinessLogicException ex)
            {
                HttpContext.Items.Add("ex", ex); //For instrumentation
                return(this.ApiErrorMessage400BadRequest(ex));
            }
            catch (Exception ex)
            {
                HttpContext.Items.Add("ex", ex); //For instrumentation
                return(StatusCode(StatusCodes.Status500InternalServerError));
            }
        }
Ejemplo n.º 5
0
        public Task <SEOResponse> GetSearchResults(string searchTerm, string resultNumber, SearchEngineType searchEngine, string searchURL)
        {
            var           searchResults       = string.Empty;
            List <string> result              = new List <string>();
            var           formattedSearchTerm = searchTerm.Replace(' ', '+');
            string        url = string.Format("https://www.{0}/search?num={1}&q={2}", EnumMapper.From(searchEngine), resultNumber, formattedSearchTerm);

            try
            {
                using (HttpResponseMessage response = _client.GetAsync(url).Result)
                {
                    using (HttpContent content = response.Content)
                    {
                        searchResults = content.ReadAsStringAsync().Result;
                    }
                }
                if (searchResults != null)
                {
                    var formattedSearchURL = FormatSearchURL(searchURL);
                    result = AdvancedScraper(searchResults, formattedSearchURL, searchEngine);
                }
            }
            catch (Exception ex)
            {
                _logger.Error(ex, "Something went wrong getting search results.");
                throw new ArgumentException();
            }

            return(Task.FromResult(new SEOResponse {
                Result = result
            }));
        }