/// <summary>
 /// This method will return all the active connections as well as invitees of the user which exists in the system.
 /// </summary>
 /// <param name="userId"></param>
 /// <param name="programId"></param>
 /// <returns></returns>
 public async Task <List <BenefactorDto> > GetUserConnections(int userId, int programId)
 {
     using (var sqlConnection = await _databaseConnectionFactory.CreateConnectionAsync())
     {
         try
         {
             var    reloadSetting = (await _setting.GetGeneratSettingValueByKeyGroup(GeneralSettingsConstants.Reload)).FirstOrDefault().Value;
             object obj           = new { UserId = userId, ProgramId = programId, Minutes = reloadSetting };
             var    result        = (await sqlConnection.QueryAsync <BenefactorDto>(SQLQueryConstants.GetUserConnectionsQuery, obj)).ToList();
             if (result.Count > 0)
             {
                 for (int i = 0; i < result.Count; i++)
                 {
                     result[i].BenefactorImage = await _photos.GetAWSBucketFilUrl(result[i].BenefactorImage, string.Concat(_configuration["ServiceAPIURL"], ImagesDefault.UserDefaultImage));
                 }
             }
             List <BenefactorDto> asList = result.OrderByDescending(x => x.CreationDate).ToList();
             return(asList);
         }
         catch (Exception)
         {
             throw;
         }
         finally
         {
             sqlConnection.Close();
             sqlConnection.Dispose();
         }
     }
 }
Exemple #2
0
        /// <summary>
        /// Get All the Programs present in the DB.
        /// </summary>
        /// <returns>Programs List</returns>
        public async Task <IEnumerable <ProgramDto> > GetPrograms()
        {
            using (var sqlConnection = await _databaseConnectionFactory.CreateConnectionAsync())
            {
                try
                {
                    var result = (await sqlConnection.QueryAsync <ProgramDto>(SQLQueryConstants.GetAllProgramsQuery, new { })).ToList();
                    if (result.Count > 0)
                    {
                        for (int i = 0; i < result.Count; i++)
                        {
                            result[i].LogoPath = await _photos.GetAWSBucketFilUrl(result[i].LogoPath, string.Concat(_configuration["ServiceAPIURL"], ImagesDefault.ProgramDefaultImage));
                        }
                    }

                    return(result);
                }
                catch (Exception)
                {
                    throw;
                }
                finally
                {
                    sqlConnection.Close();
                    sqlConnection.Dispose();
                }
            }
        }
 /// <summary>
 /// This method will get the list of Branding.
 /// </summary>
 /// <param name="programId"></param>
 /// <returns></returns>
 public async Task <IEnumerable <BrandingListingDto> > GetBrandingListing(int programId)
 {
     using (var sqlConnection = await _databaseConnectionFactory.CreateConnectionAsync())
     {
         try
         {
             var obj = new
             {
                 ProgramId = programId,
                 IsDeleted = false,
                 PhotoType = PhotoEntityType.BrandingLogo
             };
             var accountListings = (await sqlConnection.QueryAsync <BrandingListingDto>(SQLQueryConstants.GetBrandingLisitngQuery, obj)).ToList();
             if (accountListings.Count > 0)
             {
                 for (int i = 0; i < accountListings.Count; i++)
                 {
                     accountListings[i].ImagePath = await _photos.GetAWSBucketFilUrl(accountListings[i].ImagePath, string.Concat(_configuration["ServiceAPIURL"], ImagesDefault.BrandingDefaultImage));
                 }
             }
             return(accountListings.ToList());
         }
         catch (Exception)
         {
             throw;
         }
         finally
         {
             sqlConnection.Close();
             sqlConnection.Dispose();
         }
     }
 }
Exemple #4
0
        public async Task <UserDto> GetUserById(int userId)
        {
            using (var sqlConnection = await _databaseConnectionFactory.CreateConnectionAsync())
            {
                try
                {
                    var result = await sqlConnection.QuerySingleOrDefaultAsync <UserDto>(SQLQueryConstants.GetUserDetailByIdQuery, new { UserId = userId, DefaultProgramPhotoPath = string.Concat(_configuration["ServiceAPIURL"], ImagesDefault.ProgramDefaultImage) });

                    if (result != null)
                    {
                        result.ImagePath = await _photos.GetAWSBucketFilUrl(result.ImagePath, string.Concat(_configuration["ServiceAPIURL"], ImagesDefault.UserDefaultImage));
                    }
                    return(result);
                }
                catch (Exception)
                {
                    throw;
                }
                finally
                {
                    sqlConnection.Close();
                    sqlConnection.Dispose();
                }
            }
        }
Exemple #5
0
        public async Task <List <BenefactorNotificationsDto> > GetBenefactorNotifications(int benefactorId)//Left To implement Dapper
        {
            using (var sqlConnection = await _databaseConnectionFactory.CreateConnectionAsync())
            {
                try
                {
                    var user = await sqlConnection.QueryAsync <User>(SQLQueryConstants.GetUserByIdQuery, new { Id = benefactorId, IsActive = true, IsDeleted = false });

                    var userEmail = user.FirstOrDefault().Email ?? "";
                    var obj       = new
                    {
                        BenefactorId = benefactorId,
                        Email        = userEmail
                    };
                    var oNotifications = (await sqlConnection.QueryAsync <BenefactorNotificationsDto>(SQLQueryConstants.GetBenefactorNotificationQuery, obj)).ToList();
                    if (oNotifications.Count() > 0)
                    {
                        for (int i = 0; i < oNotifications.Count; i++)
                        {
                            oNotifications[i].ImagePath = await _photos.GetAWSBucketFilUrl(oNotifications[i].ImagePath, string.Concat(_configuration["ServiceAPIURL"], ImagesDefault.UserDefaultImage));
                        }
                    }
                    return(oNotifications.OrderByDescending(x => x.ModifiedDate).ToList());
                }
                catch (Exception)
                {
                    throw;
                }
                finally
                {
                    sqlConnection.Close();
                    sqlConnection.Dispose();
                }
            }
        }
Exemple #6
0
 public async Task <PromotionsDto> GetPromotionDetailById(int promotionId)
 {
     using (var sqlConnection = await _databaseConnectionFactory.CreateConnectionAsync())
     {
         try
         {
             var result = (await sqlConnection.QueryAsync <PromotionsDto>(SQLQueryConstants.GetPromotionsOfMerchantByIdQuery, new { PromotionId = promotionId })).FirstOrDefault();
             if (result != null)
             {
                 result.ImageFileName = result.ImagePath;
                 result.ImagePath     = await _photos.GetAWSBucketFilUrl(result.ImagePath, string.Concat(_configuration["ServiceAPIURL"], ImagesDefault.PromotionDefaultImage));
             }
             return(result);
         }
         catch (Exception)
         {
             throw;
         }
         finally
         {
             sqlConnection.Close();
             sqlConnection.Dispose();
         }
     }
 }
Exemple #7
0
        public async Task <IActionResult> GetPreSignedURLFromFileName(string fileName)
        {
            try
            {
                var result = await _entityPhotos.GetAWSBucketFilUrl(fileName, null);

                return(Ok(new ApiResponse(Microsoft.AspNetCore.Http.StatusCodes.Status200OK, true, MessagesConstants.ImageReturnedSuccessfully, result)));
            }
            catch (Exception ex)
            {
                HttpContext.RiseError(new Exception(string.Concat("API := (Image := RemoveImage)", ex.Message, " Stack Trace : ", ex.StackTrace, " Inner Exception : ", ex.InnerException)));
                return(Ok(someIssueInProcessing));
            }
        }
 public async Task <List <LinkedUsersTransactionsDto> > GetRespectiveUsersTransactions(int userId, DateTime?dateMonth, int?programId)
 {
     using (var sqlConnection = await _databaseConnectionFactory.CreateConnectionAsync())
     {
         try
         {
             var transactions = (await sqlConnection.QueryAsync <LinkedUsersTransactionsDto>(SQLQueryConstants.GetRespectiveUserTransaction, new { linkedUserId = userId, DateMonth = dateMonth, ProgramId = programId, photoType = (int)PhotoEntityType.Organisation, DefaultImagePath = string.Concat(_configuration["ServiceAPIURL"], ImagesDefault.MerchantDefaultImage) })).ToList();
             for (int i = 0; i < transactions.Count; i++)
             {
                 transactions[i].ImagePath = await _photos.GetAWSBucketFilUrl(transactions[i].ImagePath, string.Concat(_configuration["ServiceAPIURL"], ImagesDefault.MerchantDefaultImage));
             }
             return(transactions);
         }
         catch (Exception)
         {
             throw;
         }
         finally
         {
             sqlConnection.Close();
             sqlConnection.Dispose();
         }
     }
 }