Esempio n. 1
0
        public async Task <DatabaseResponse> ValidateResetPasswordToken(string token)
        {
            try
            {
                SqlParameter[] parameters =
                {
                    new SqlParameter("@Token", SqlDbType.NVarChar)
                };

                parameters[0].Value = token;

                _DataHelper = new DataAccessHelper("Customer_ValidateResetPasswordToken", parameters, _configuration);

                int result = await _DataHelper.RunAsync(); // 124 /125

                DatabaseResponse response = new DatabaseResponse();

                response = new DatabaseResponse {
                    ResponseCode = result
                };

                return(response);
            }

            catch (Exception ex)
            {
                LogInfo.Error(new ExceptionHelper().GetLogString(ex, ErrorLevel.Critical));

                throw (ex);
            }
            finally
            {
                _DataHelper.Dispose();
            }
        }
Esempio n. 2
0
        public async Task <IActionResult> GetConfigValue([FromHeader] string Token, [FromRoute] string ConfigKey)
        {
            try
            {
                if (string.IsNullOrEmpty(ConfigKey))
                {
                    return(Ok(new OperationResponse
                    {
                        HasSucceeded = false,
                        Message = StatusMessages.DomainValidationError,
                        IsDomainValidationErrors = true
                    }));
                }

                ConfigDataAccess _configAccess = new ConfigDataAccess(_iconfiguration);

                return(Ok(new ServerResponse
                {
                    HasSucceeded = true,
                    Message = StatusMessages.SuccessMessage,
                    Result = await _configAccess.GetConfigValue(ConfigKey, Token)
                }));
            }
            catch (Exception ex)
            {
                LogInfo.Error(new ExceptionHelper().GetLogString(ex, ErrorLevel.Critical));

                return(Ok(new OperationResponse
                {
                    HasSucceeded = false,
                    Message = StatusMessages.ServerError,
                    IsDomainValidationErrors = false
                }));
            }
        }
Esempio n. 3
0
        public List <RewardDetails> GetRewardDetails(string RequestUrl, int AccountID, DateTime FromDate, DateTime ToDate)
        {
            List <RewardDetails> _resp = null;

            try
            {
                ApiClient client     = new ApiClient(new Uri(RequestUrl));
                var       requestUrl = GetRequestUrl(RequestUrl, ref client);

                RequestObject req  = new RequestObject();
                string        html = string.Empty;
                string        url  = requestUrl + $"{AccountID}?startDate={FromDate.ToString("yyyyMMdd")}&endDate={ToDate.ToString("yyyyMMdd")}";

                HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
                request.AutomaticDecompression = DecompressionMethods.GZip;

                using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
                    using (Stream stream = response.GetResponseStream())
                        using (StreamReader reader = new StreamReader(stream))
                        {
                            html = reader.ReadToEnd();
                        }
                _resp = JsonConvert.DeserializeObject <List <RewardDetails> >(html);
            }
            catch (Exception ex)
            {
                LogInfo.Error(new ExceptionHelper().GetLogString(ex, ErrorLevel.Critical));
                throw;
            }
            return(_resp);
        }
Esempio n. 4
0
        public Rewards GetRewardSummary(string RequestUrl, int AccountID)
        {
            Rewards _resp = null;

            try
            {
                ApiClient client     = new ApiClient(new Uri(RequestUrl));
                var       requestUrl = GetRequestUrl(RequestUrl, ref client);

                RequestObject req  = new RequestObject();
                string        html = string.Empty;
                string        url  = requestUrl + $"{AccountID}";

                HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
                request.AutomaticDecompression = DecompressionMethods.GZip;

                using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
                    using (Stream stream = response.GetResponseStream())
                        using (StreamReader reader = new StreamReader(stream))
                        {
                            html = reader.ReadToEnd();
                        }
                _resp = JsonConvert.DeserializeObject <Rewards>(html);
            }
            catch (Exception ex)
            {
                LogInfo.Error(new ExceptionHelper().GetLogString(ex, ErrorLevel.Critical));
                throw;
            }
            return(_resp);
        }
Esempio n. 5
0
        public async Task <DatabaseResponse> ResetPassword(ResetPassword resetPassword)
        {
            try
            {
                SqlParameter[] parameters =
                {
                    new SqlParameter("@Token",    SqlDbType.NVarChar),

                    new SqlParameter("@Password", SqlDbType.NVarChar)
                };

                parameters[0].Value = resetPassword.ResetToken;

                parameters[1].Value = new Sha2().Hash(new Base64Helper().base64Decode(resetPassword.NewPassword));

                _DataHelper = new DataAccessHelper("Customer_ResetPassword", parameters, _configuration);

                int result = await _DataHelper.RunAsync();

                return(new DatabaseResponse {
                    ResponseCode = result
                });
            }

            catch (Exception ex)
            {
                LogInfo.Error(new ExceptionHelper().GetLogString(ex, ErrorLevel.Critical));

                throw (ex);
            }
            finally
            {
                _DataHelper.Dispose();
            }
        }
Esempio n. 6
0
        public async Task <List <Bundle> > GetBundleList(string code)
        {
            try
            {
                if (code != "")
                {
                    SqlParameter[] parameters =
                    {
                        new SqlParameter("@UserCode", SqlDbType.NVarChar)
                    };
                    parameters[0].Value = code;

                    _DataHelper = new DataAccessHelper("Catelog_GetBundlesListing", parameters, _configuration);
                }
                else
                {
                    _DataHelper = new DataAccessHelper("Catelog_GetBundlesListing", _configuration);
                }
                DataTable dt = new DataTable();

                await _DataHelper.RunAsync(dt);

                List <Bundle> bundleList = new List <Bundle>();

                if (dt.Rows.Count > 0)
                {
                    bundleList = (from model in dt.AsEnumerable()
                                  select new Bundle()
                    {
                        BundleID = model.Field <int>("BundleID"),
                        BundleName = model.Field <string>("BundleName"),
                        PortalDescription = model.Field <string>("PortalDescription"),
                        PlanMarketingName = model.Field <string>("PlanMarketingName"),
                        PortalSummaryDescription = model.Field <string>("PortalSummaryDescription"),
                        ServiceName = model.Field <string>("ServiceName"),
                        ActualServiceFee = model.Field <double>("ActualServiceFee"),
                        ActualSubscriptionFee = model.Field <double>("ActualSubscriptionFee"),
                        ApplicableServiceFee = model.Field <double>("ApplicableServiceFee"),
                        ApplicableSubscriptionFee = model.Field <double>("ApplicableSubscriptionFee"),
                        TotalData = model.Field <double>("TotalData"),
                        TotalSMS = model.Field <double>("TotalSMS"),
                        TotalVoice = model.Field <double>("TotalVoice"),
                        PromotionText = model.Field <string>("PromotionText"),
                        PricingDescription = model.Field <string>("PricingDescription")
                    }).ToList();
                }

                return(bundleList);
            }

            catch (Exception ex)
            {
                LogInfo.Error(new ExceptionHelper().GetLogString(ex, ErrorLevel.Critical));
                throw (ex);
            }
            finally
            {
                _DataHelper.Dispose();
            }
        }
Esempio n. 7
0
        private static int GetIntervel()
        {
            try
            {
                DatabaseResponse intervelConfigResponse = new DatabaseResponse();

                intervelConfigResponse = ConfigHelper.GetValueByKey(ConfigKeys.BuddyTrialIntervel.ToString(), _connectionString);

                if (intervelConfigResponse != null && intervelConfigResponse.ResponseCode == (int)DbReturnValue.RecordExists)
                {
                    string configValue = (string)intervelConfigResponse.Results;

                    return(int.Parse(configValue));
                }

                else
                {
                    return(0);
                }
            }
            catch (Exception ex)
            {
                LogInfo.Error(new ExceptionHelper().GetLogString(ex, ErrorLevel.Critical));

                return(0);
            }
        }
Esempio n. 8
0
        static void Main(string[] args)
        {
            try
            {
                LogInfo.Initialize(Configuration);

                LogInfo.Information("Buddy Console App is Started");

                _connectionString = Configuration.GetConnectionString("DefaultConnection");

                _timeInterval = GetIntervel();

                bool complete = false;

                var t = new Thread(() =>
                {
                    bool toggle = false;
                    while (!complete)
                    {
                        toggle = !toggle;

                        TimerCallback();
                        Thread.Sleep(_timeInterval);
                    }
                });
                t.Start();
                complete = false;
                t.Join();
            }
            catch (Exception ex)
            {
                LogInfo.Error(new ExceptionHelper().GetLogString(ex, ErrorLevel.Critical));
            }
        }
Esempio n. 9
0
        /// <summary>
        /// Grids the process vas addition.
        /// </summary>
        /// <param name="ChangeRequestID">The change request identifier.</param>
        /// <param name="Status">The status.</param>
        /// <param name="ValidFrom">The valid from.</param>
        /// <param name="ValidTo">The valid to.</param>
        /// <returns></returns>
        public async Task <int> Grid_ProcessVASAddition(int ChangeRequestID, int Status, DateTime ValidFrom, DateTime ValidTo)
        {
            try
            {
                SqlParameter[] parameters =
                {
                    new SqlParameter("@ChangeRequestID", SqlDbType.Int),
                    new SqlParameter("@Status",          SqlDbType.Int),
                    new SqlParameter("@ValidFrom",       SqlDbType.Date),
                    new SqlParameter("@ValidTo",         SqlDbType.Date),
                };

                parameters[0].Value = ChangeRequestID;
                parameters[1].Value = Status;
                parameters[2].Value = ValidFrom.Date;
                parameters[3].Value = ValidTo.Date;



                _DataHelper = new DataAccessHelper("Grid_ProcessVASAddition", parameters, _configuration);
                DataTable dt = new DataTable();
                return(await _DataHelper.RunAsync());
            }

            catch (Exception ex)
            {
                LogInfo.Error(new ExceptionHelper().GetLogString(ex, ErrorLevel.Critical));

                throw;
            }
            finally
            {
                _DataHelper.Dispose();
            }
        }
Esempio n. 10
0
        /// <summary>
        /// Grids the update order status.
        /// </summary>
        /// <param name="request">The request.</param>
        /// <returns></returns>
        public async Task <int> Grid_UpdateOrderStatus(UpdateOrderStatus request)
        {
            try
            {
                SqlParameter[] parameters =
                {
                    new SqlParameter("@OrderID",      SqlDbType.Int),
                    new SqlParameter("@OrderNumber",  SqlDbType.NVarChar),
                    new SqlParameter("@Orderstatus",  SqlDbType.NVarChar),
                    new SqlParameter("@error_reason", SqlDbType.NVarChar),
                };

                parameters[0].Value = request.OrderID;
                parameters[1].Value = request.OrderNumber;
                parameters[2].Value = request.Orderstatus;
                parameters[3].Value = request.error_reason;


                _DataHelper = new DataAccessHelper("Grid_UpdateOrderStatus", parameters, _configuration);
                DataTable dt = new DataTable();
                return(await _DataHelper.RunAsync());
            }

            catch (Exception ex)
            {
                LogInfo.Error(new ExceptionHelper().GetLogString(ex, ErrorLevel.Critical));

                throw;
            }
            finally
            {
                _DataHelper.Dispose();
            }
        }
Esempio n. 11
0
        public async Task <DatabaseResponse> ValidateUserCode(string UserCode)
        {
            try
            {
                string         ename      = "";
                SqlParameter[] parameters =
                {
                    new SqlParameter("@UserCode", SqlDbType.NVarChar),
                };
                parameters[0].Value = UserCode;
                DataSet ds = new DataSet("ds");
                _DataHelper = new DataAccessHelper("Customers_ValidateUserCode", parameters, _configuration);
                int result = await _DataHelper.RunAsync(ds); //103/150,

                if (ds.Tables[0].Rows.Count > 0)
                {
                    ename = ds.Tables[0].Rows[0][0].ToString().Trim();
                }
                DatabaseResponse response = new DatabaseResponse();

                response = new DatabaseResponse {
                    ResponseCode = result, Results = ename
                };

                return(response);
            }
            catch (Exception e)
            {
                LogInfo.Error(new ExceptionHelper().GetLogString(e, ErrorLevel.Critical));
                throw e;
            }
        }
Esempio n. 12
0
        /// <summary>
        /// Updates the customer account accessibility.
        /// </summary>
        /// <param name="Token">The token.</param>
        /// <param name="CustomerID">The customer identifier.</param>
        /// <param name="Status">The status.</param>
        /// <returns></returns>
        public async Task <DatabaseResponse> UpdateCustomerAccountAccessibility(string Token, int CustomerID, int Status)
        {
            try
            {
                SqlParameter[] parameters =
                {
                    new SqlParameter("@CustomerID",   SqlDbType.Int),
                    new SqlParameter("@UpdatorToken", SqlDbType.VarChar),
                    new SqlParameter("@Status",       SqlDbType.Int)
                };

                parameters[0].Value = CustomerID;
                parameters[1].Value = Token;
                parameters[2].Value = Status;

                _DataHelper = new DataAccessHelper("Admin_UpdateCustomerAccountAccessibility", parameters, _configuration);

                int result = await _DataHelper.RunAsync(); //101,106,102,143 - admin token not matching

                return(new DatabaseResponse {
                    ResponseCode = result
                });
            }
            catch (Exception ex)
            {
                LogInfo.Error(new ExceptionHelper().GetLogString(ex, ErrorLevel.Critical));

                throw ex;
            }
            finally
            {
                _DataHelper.Dispose();
            }
        }
Esempio n. 13
0
        /// <summary>
        /// Updates the message queue object to table.
        /// </summary>
        /// <param name="updateQueue">The update queue.</param>
        /// <returns></returns>
        private async Task <int> UpdateMessageQueueObjectToTable(MessageQueueRequest updateQueue)
        {
            var _DataHelper = new DataAccessHelper(Core.Enums.DbObjectNames.z_UpdateStatusInMessageQueueRequests, _connectionString);

            try
            {
                SqlParameter[] parameters =
                {
                    new SqlParameter("@MessageQueueRequestID", SqlDbType.Int),
                    new SqlParameter("@Status",                SqlDbType.Int),
                    new SqlParameter("@PublishedOn",           SqlDbType.DateTime),
                    new SqlParameter("@NumberOfRetries",       SqlDbType.Int),
                    new SqlParameter("@LastTriedOn",           SqlDbType.DateTime),
                };

                parameters[0].Value = updateQueue.MessageQueueRequestID;
                parameters[1].Value = updateQueue.Status;
                parameters[2].Value = updateQueue.PublishedOn;
                parameters[3].Value = updateQueue.NumberOfRetries;
                parameters[4].Value = updateQueue.LastTriedOn;

                _DataHelper = new DataAccessHelper(Core.Enums.DbObjectNames.z_UpdateStatusInMessageQueueRequests, parameters, _connectionString);
                return(await _DataHelper.RunAsync());
            }
            catch (Exception ex)
            {
                LogInfo.Error(new ExceptionHelper().GetLogString(ex, ErrorLevel.Critical));
                Console.WriteLine("Critical error in UpdateMessageQueueObjectToTable. Exception is as follows \n " + ex);
                return(0);
            }
            finally
            {
                _DataHelper.Dispose();
            }
        }
Esempio n. 14
0
        /// <summary>
        /// Creates the e mail notification log.
        /// </summary>
        /// <param name="log">The log.</param>
        /// <returns></returns>
        public async Task <DatabaseResponse> CreateEMailNotificationLog(NotificationLog log)
        {
            try
            {
                SqlParameter[] parameters =
                {
                    new SqlParameter("@CustomerID",      SqlDbType.Int),

                    new SqlParameter("@Email",           SqlDbType.NVarChar),

                    new SqlParameter("@EmailSubject",    SqlDbType.NVarChar),

                    new SqlParameter("@EmailBody",       SqlDbType.NVarChar),

                    new SqlParameter("@ScheduledOn",     SqlDbType.DateTime),

                    new SqlParameter("@EmailTemplateID", SqlDbType.Int),

                    new SqlParameter("@SendOn",          SqlDbType.DateTime),

                    new SqlParameter("@Status",          SqlDbType.Int)
                };

                parameters[0].Value = log.CustomerID;
                parameters[1].Value = log.Email;
                parameters[2].Value = log.EmailSubject;
                parameters[3].Value = log.EmailBody;
                parameters[4].Value = log.ScheduledOn;
                parameters[5].Value = log.EmailTemplateID;
                parameters[6].Value = log.SendOn;
                parameters[7].Value = log.Status;


                _DataHelper = new DataAccessHelper("z_EmailNotificationsLogEntry", parameters, _configuration);

                DataTable dt = new DataTable();

                int result = await _DataHelper.RunAsync(dt); // 107 /100

                DatabaseResponse response = new DatabaseResponse();

                response = new DatabaseResponse {
                    ResponseCode = result
                };


                return(response);
            }

            catch (Exception ex)
            {
                LogInfo.Error(new ExceptionHelper().GetLogString(ex, ErrorLevel.Critical));

                throw (ex);
            }
            finally
            {
                _DataHelper.Dispose();
            }
        }
Esempio n. 15
0
        /// <summary>
        /// Grids the state of the update subscriber.
        /// </summary>
        /// <param name="SubscriberID">The subscriber identifier.</param>
        /// <param name="state">The state.</param>
        /// <param name="error_reason">The error reason.</param>
        /// <returns></returns>
        public async Task <int> Grid_UpdateSubscriberState(int SubscriberID, string state, string error_reason)
        {
            try
            {
                SqlParameter[] parameters =
                {
                    new SqlParameter("@SubscriberID", SqlDbType.Int),
                    new SqlParameter("@state",        SqlDbType.NVarChar),
                    new SqlParameter("@error_reason", SqlDbType.NVarChar),
                };

                parameters[0].Value = SubscriberID;
                parameters[1].Value = state;
                parameters[2].Value = error_reason;


                _DataHelper = new DataAccessHelper("Grid_UpdateSubscriberState", parameters, _configuration);
                DataTable dt = new DataTable();
                return(await _DataHelper.RunAsync());
            }

            catch (Exception ex)
            {
                LogInfo.Error(new ExceptionHelper().GetLogString(ex, ErrorLevel.Critical));

                throw;
            }
            finally
            {
                _DataHelper.Dispose();
            }
        }
Esempio n. 16
0
        public async Task <IActionResult> GetPageFAQ([FromHeader(Name = "Grid-General-Token")] string Token, [FromRoute] string Pagename)
        {
            try
            {
                if (string.IsNullOrEmpty(Pagename))
                {
                    return(Ok(new OperationResponse
                    {
                        HasSucceeded = false,
                        Message = StatusMessages.DomainValidationError,
                        IsDomainValidationErrors = true
                    }));
                }

                TokenValidationHelper tokenValidationHelper = new TokenValidationHelper();
                if (!tokenValidationHelper.ValidateGenericToken(Token, _iconfiguration))
                {
                    return(Ok(new OperationResponse
                    {
                        HasSucceeded = false,
                        Message = Core.Extensions.EnumExtensions.GetDescription(DbReturnValue.TokenAuthFailed),
                        IsDomainValidationErrors = true
                    }));
                }

                FaqPageDataAccess _FaqPageDataAccess = new FaqPageDataAccess(_iconfiguration);

                List <FaqPages> faqresult = await _FaqPageDataAccess.GetPageFAQ(Pagename);

                string faqmessage;

                if (faqresult != null && faqresult.Count > 0)
                {
                    faqmessage = StatusMessages.SuccessMessage;
                }
                else
                {
                    faqmessage = "Faq not found";
                }


                return(Ok(new ServerResponse
                {
                    HasSucceeded = true,
                    Message = faqmessage,
                    Result = faqresult
                }));
            }
            catch (Exception ex)
            {
                LogInfo.Error(new ExceptionHelper().GetLogString(ex, ErrorLevel.Critical));

                return(Ok(new OperationResponse
                {
                    HasSucceeded = false,
                    Message = StatusMessages.ServerError,
                    IsDomainValidationErrors = false
                }));
            }
        }
Esempio n. 17
0
        public async Task <DatabaseResponse> ValidatePostcode(string _postcode)
        {
            try
            {
                PostCodeRequest  _postcodedata  = new PostCodeRequest();
                DatabaseResponse configResponse = ConfigHelper.GetValue("Postcode", _configuration);

                List <Dictionary <string, string> > _result = ((List <Dictionary <string, string> >)configResponse.Results);

                _postcodedata.APIKey    = _result.Single(x => x["key"] == "PostcodeApiKey")["value"];
                _postcodedata.APISecret = _result.Single(x => x["key"] == "PostcodeSecret")["value"];
                _postcodedata.Postcode  = _postcode;
                string Postcodeurl = _result.Single(x => x["key"] == "Postcodeurl")["value"];

                byte[] buffer;
                string postData = string.Empty;

                postData = string.Format("APIKey={0}&APISecret={1}&Postcode={2}", _postcodedata.APIKey, _postcodedata.APISecret, _postcode);
                buffer   = Encoding.UTF8.GetBytes(postData);

                System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls12;

                HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create(Postcodeurl);
                myRequest.Method        = "POST";
                myRequest.ContentType   = "application/x-www-form-urlencoded";
                myRequest.ContentLength = buffer.Length;
                Stream newStream = myRequest.GetRequestStream();
                await newStream.WriteAsync(buffer, 0, buffer.Length);

                newStream.Close();
                HttpWebResponse myHttpWebResponse = (HttpWebResponse)myRequest.GetResponse();

                Stream        streamResponse = myHttpWebResponse.GetResponseStream();
                StreamReader  streamRead     = new StreamReader(streamResponse);
                Char[]        readBuffer     = new Char[256];
                int           count          = streamRead.Read(readBuffer, 0, 256);
                StringBuilder Result         = new StringBuilder();
                while (count > 0)
                {
                    String resultData = new String(readBuffer, 0, count);
                    Result.Append(resultData);
                    count = streamRead.Read(readBuffer, 0, 256);
                }
                streamRead.Close();
                streamResponse.Close();
                myHttpWebResponse.Close();

                dynamic data = JsonConvert.DeserializeObject(Result.ToString());

                return(new DatabaseResponse {
                    Results = data
                });
            }

            catch (Exception e)
            {
                LogInfo.Error(new ExceptionHelper().GetLogString(e, ErrorLevel.Critical));
                throw e;
            }
        }
Esempio n. 18
0
        public async Task <string> SendOrderSuccessSMSNotification(CustomerDetails customer, IConfiguration _configuration)
        {
            string status = string.Empty;

            try
            {
                ConfigDataAccess _configAccess = new ConfigDataAccess(_configuration);

                DatabaseResponse smsTemplateResponse = await _configAccess.GetSMSNotificationTemplate(NotificationEvent.OrderSuccess.ToString());

                var notificationMessage = MessageHelper.GetSMSMessage(NotificationEvent.OrderSuccess.ToString(), ((SMSTemplates)smsTemplateResponse.Results).TemplateName, customer.Name, customer.DeliveryEmail, customer.ShippingContactNumber, customer.OrderNumber, customer.SlotDate.ToString("dd MMM yyyy"), new DateTime(customer.SlotFromTime.Ticks).ToString("hh:mm tt") + " to " + new DateTime(customer.SlotToTime.Ticks).ToString("hh:mm tt"));

                DatabaseResponse notificationResponse = await _configAccess.GetConfiguration(ConfiType.Notification.ToString());

                MiscHelper parser = new MiscHelper();

                var notificationConfig = parser.GetNotificationConfig((List <Dictionary <string, string> >)notificationResponse.Results);

                Publisher orderSuccessSMSNotificationPublisher = new Publisher(_configuration, notificationConfig.SNSTopic);

                status = await orderSuccessSMSNotificationPublisher.PublishAsync(notificationMessage);

                LogInfo.Information("SMS send status : " + status + " " + JsonConvert.SerializeObject(notificationMessage));

                return(status);
            }
            catch (Exception ex)
            {
                LogInfo.Error(new ExceptionHelper().GetLogString(ex, ErrorLevel.Critical) + "SMS failure for OrderNumber:" + customer.OrderNumber);

                throw ex;
            }
        }
Esempio n. 19
0
        /// <summary>
        /// Grids the update billing account.
        /// </summary>
        /// <param name="AccountID">The account identifier.</param>
        /// <param name="BillingAccountNumber">The billing account number.</param>
        /// <param name="BSSProfileid">The BSS profileid.</param>
        /// <returns></returns>
        public async Task <int> Grid_UpdateBillingAccount(string AccountID, string BillingAccountNumber, string BSSProfileid)
        {
            try
            {
                SqlParameter[] parameters =
                {
                    new SqlParameter("@AccountID",            SqlDbType.Int),
                    new SqlParameter("@BillingAccountNumber", SqlDbType.NVarChar),
                    new SqlParameter("@BSSProfileid",         SqlDbType.NVarChar),
                };

                parameters[0].Value = AccountID;
                parameters[1].Value = BillingAccountNumber;
                parameters[2].Value = BSSProfileid;

                _DataHelper = new DataAccessHelper("Grid_UpdateBillingAccount", parameters, _configuration);
                DataTable dt = new DataTable();
                return(await _DataHelper.RunAsync());
            }

            catch (Exception ex)
            {
                LogInfo.Error(new ExceptionHelper().GetLogString(ex, ErrorLevel.Critical));

                throw;
            }
            finally
            {
                _DataHelper.Dispose();
            }
        }
Esempio n. 20
0
        public async Task <IActionResult> Log([FromBody] UILog logRequest)
        {
            try
            {
                if (logRequest == null || string.IsNullOrEmpty(logRequest.Message))
                {
                    return(Ok(new OperationResponse
                    {
                        HasSucceeded = false,
                        Message = StatusMessages.DomainValidationError,
                        IsDomainValidationErrors = true
                    }));
                }

                await Task.Run(() =>
                {
                    LogInfo.Error(JsonConvert.SerializeObject(logRequest));
                });


                return(Ok());
            }
            catch (Exception ex)
            {
                LogInfo.Error(new ExceptionHelper().GetLogString(ex, ErrorLevel.Critical));

                return(Ok(new OperationResponse
                {
                    HasSucceeded = false,
                    Message = StatusMessages.ServerError,
                    IsDomainValidationErrors = false
                }));
            }
        }
Esempio n. 21
0
        /// <summary>
        /// Grids the process change sim.
        /// </summary>
        /// <param name="ChangeRequestID">The change request identifier.</param>
        /// <param name="Status">The status.</param>
        /// <param name="SIMID">The simid.</param>
        /// <param name="SusbcriberStateUpdate">The susbcriber state update.</param>
        /// <returns></returns>
        public async Task <int> Grid_ProcessChangeSim(int ChangeRequestID, int Status, string SIMID, int SusbcriberStateUpdate)
        {
            try
            {
                SqlParameter[] parameters =
                {
                    new SqlParameter("@ChangeRequestID",       SqlDbType.Int),
                    new SqlParameter("@Status",                SqlDbType.Int),
                    new SqlParameter("@SIMID",                 SqlDbType.NVarChar),
                    new SqlParameter("@SusbcriberStateUpdate", SqlDbType.Int),
                };

                parameters[0].Value = ChangeRequestID;
                parameters[1].Value = Status;
                parameters[2].Value = SIMID;
                parameters[3].Value = SusbcriberStateUpdate;



                _DataHelper = new DataAccessHelper("Grid_ProcessChangeSim", parameters, _configuration);
                DataTable dt = new DataTable();
                return(await _DataHelper.RunAsync());
            }

            catch (Exception ex)
            {
                LogInfo.Error(new ExceptionHelper().GetLogString(ex, ErrorLevel.Critical));

                throw;
            }
            finally
            {
                _DataHelper.Dispose();
            }
        }
Esempio n. 22
0
        /// <summary>
        /// Grids the update vendor tracking code.
        /// </summary>
        /// <param name="DeliveryinformationID">The deliveryinformation identifier.</param>
        /// <param name="TrackingCode">The tracking code.</param>
        /// <returns></returns>
        public async Task <int> Grid_UpdateVendorTrackingCode(int DeliveryinformationID, string TrackingCode)
        {
            try
            {
                SqlParameter[] parameters =
                {
                    new SqlParameter("@DeliveryinformationID", SqlDbType.Int),
                    new SqlParameter("@TrackingCode",          SqlDbType.NVarChar)
                };

                parameters[0].Value = DeliveryinformationID;
                parameters[1].Value = TrackingCode;



                _DataHelper = new DataAccessHelper("Grid_UpdateVendorTrackingCode", parameters, _configuration);
                DataTable dt = new DataTable();
                return(await _DataHelper.RunAsync());
            }

            catch (Exception ex)
            {
                LogInfo.Error(new ExceptionHelper().GetLogString(ex, ErrorLevel.Critical));

                throw;
            }
            finally
            {
                _DataHelper.Dispose();
            }
        }
Esempio n. 23
0
        public async Task <IActionResult> GetTokenDetails([FromRoute] string token)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    new OperationResponse
                    {
                        HasSucceeded             = false,
                        IsDomainValidationErrors = true,
                        Message = string.Join("; ", ModelState.Values
                                              .SelectMany(x => x.Errors)
                                              .Select(x => x.ErrorMessage))
                    };
                }

                AccountDataAccess _AccountAccess = new AccountDataAccess(_iconfiguration);

                DatabaseResponse response = await _AccountAccess.AuthenticateToken(token);

                if (response.ResponseCode == 105)
                {
                    //Authentication success

                    var _accesstoken = new AccessToken();

                    _accesstoken = (AccessToken)response.Results;

                    // return basic user info (without password) and token to store client side
                    return(Ok(new OperationResponse
                    {
                        HasSucceeded = true,
                        Message = EnumExtensions.GetDescription(DbReturnValue.AuthSuccess),
                        ReturnedObject = _accesstoken
                    }));
                }

                else
                {
                    return(Ok(new OperationResponse
                    {
                        HasSucceeded = false,
                        Message = EnumExtensions.GetDescription(DbReturnValue.ReasonUnknown),
                        IsDomainValidationErrors = true
                    }));
                }
            }
            catch (Exception ex)
            {
                LogInfo.Error(new ExceptionHelper().GetLogString(ex, ErrorLevel.Critical));

                return(Ok(new OperationResponse
                {
                    HasSucceeded = false,
                    Message = StatusMessages.ServerError,
                    IsDomainValidationErrors = false
                }));
            }
        }
Esempio n. 24
0
        public async Task <List <OrderList> > GetOrdersList(int?deliveryStatus, DateTime?fromDate, DateTime?toDate)
        {
            try
            {
                SqlParameter[] parameters =
                {
                    new SqlParameter("@IDVerificationStatus", SqlDbType.Int),
                    new SqlParameter("@FromDate",             SqlDbType.DateTime),
                    new SqlParameter("@ToDate",               SqlDbType.DateTime)
                };

                parameters[0].Value = deliveryStatus;
                parameters[1].Value = fromDate;
                parameters[2].Value = toDate;
                _DataHelper         = new DataAccessHelper(DbObjectNames.Admin_GetOrderListForNRIC, parameters, _configuration);

                DataTable dt = new DataTable();

                await _DataHelper.RunAsync(dt);

                List <OrderList> orderLists = new List <OrderList>();

                if (dt.Rows.Count > 0)
                {
                    orderLists = (from model in dt.AsEnumerable()
                                  select new OrderList()
                    {
                        OrderID = model.Field <int>("OrderID"),
                        OrderNumber = model.Field <string>("OrderNumber"),
                        IDVerificationStatus = model.Field <string>("IDVerificationStatus"),
                        IsIDReUploaded = model.Field <int?>("IsIDReUploaded"),
                        IDVerificationStatusNumber = model.Field <int?>("IDVerificationStatusNumber"),
                        OrderStatus = model.Field <string>("OrderStatus"),
                        OrderStatusNumber = model.Field <int?>("OrderStatusNumber"),
                        RejectionCount = model.Field <int?>("RejectionCount"),
                        Name = model.Field <string>("Name"),
                        OrderDate = model.Field <DateTime?>("OrderDate"),
                        DeliveryDate = model.Field <DateTime?>("DeliveryDate"),
                        DeliveryFromTime = model.Field <TimeSpan?>("DeliveryFromTime"),
                        DeliveryToTime = model.Field <TimeSpan?>("DeliveryToTime"),
                        IdentityCardNumber = model.Field <string>("IdentityCardNumber"),
                        IdentityCardType = model.Field <string>("IdentityCardType")
                    }).ToList();
                }

                return(orderLists);
            }

            catch (Exception ex)
            {
                LogInfo.Error(new ExceptionHelper().GetLogString(ex, ErrorLevel.Critical));

                throw (ex);
            }
            finally
            {
                _DataHelper.Dispose();
            }
        }
Esempio n. 25
0
        /// <summary>
        /// Gets the email notification template.
        /// </summary>
        /// <param name="templateName">Name of the template.</param>
        /// <returns></returns>
        public async Task <DatabaseResponse> GetEmailNotificationTemplate(string templateName)
        {
            try
            {
                SqlParameter[] parameters =
                {
                    new SqlParameter("@TemplateName", SqlDbType.NVarChar)
                };

                parameters[0].Value = templateName;

                _DataHelper = new DataAccessHelper("z_GetEmailTemplateByName", parameters, _configuration);

                DataTable dt = new DataTable();

                int result = await _DataHelper.RunAsync(dt); // 109 /105

                DatabaseResponse response = new DatabaseResponse();

                EmailTemplate template = new EmailTemplate();

                if (dt != null && dt.Rows.Count > 0)
                {
                    template = (from model in dt.AsEnumerable()
                                select new EmailTemplate()
                    {
                        EmailTemplateID = model.Field <int>("EmailTemplateID"),
                        EmailBody = model.Field <string>("EmailBody"),
                        EmailSubject = model.Field <string>("EmailSubject"),
                        TemplateName = model.Field <string>("TemplateName")
                    }).FirstOrDefault();

                    response = new DatabaseResponse {
                        ResponseCode = result, Results = template
                    };
                }


                else
                {
                    response = new DatabaseResponse {
                        ResponseCode = result
                    };
                }

                return(response);
            }

            catch (Exception ex)
            {
                LogInfo.Error(new ExceptionHelper().GetLogString(ex, ErrorLevel.Critical));

                throw (ex);
            }
            finally
            {
                _DataHelper.Dispose();
            }
        }
Esempio n. 26
0
        public async Task <DatabaseResponse> GetForgetPassword(string email)
        {
            try
            {
                SqlParameter[] parameters =
                {
                    new SqlParameter("@EmailAddress", SqlDbType.VarChar)
                };

                parameters[0].Value = email;

                _DataHelper = new DataAccessHelper("Customer_ForgotPassword", parameters, _configuration);

                DataTable dt = new DataTable();

                int result = await _DataHelper.RunAsync(dt); //111/107/109

                ForgetPassword changePasswordToken = new ForgetPassword();

                DatabaseResponse response = new DatabaseResponse();

                if (dt != null && dt.Rows.Count > 0)
                {
                    changePasswordToken = (from model in dt.AsEnumerable()
                                           select new ForgetPassword()
                    {
                        CustomerId = model.Field <int>("CustomerID"),
                        Token = model.Field <string>("Token"),
                        Name = model.Field <string>("Name"),
                        Email = model.Field <string>("Email")
                    }).FirstOrDefault();

                    response = new DatabaseResponse {
                        ResponseCode = result, Results = changePasswordToken
                    };
                }

                else
                {
                    response = new DatabaseResponse {
                        ResponseCode = result
                    };
                }

                return(response);
            }
            catch (Exception ex)
            {
                LogInfo.Error(new ExceptionHelper().GetLogString(ex, ErrorLevel.Critical));

                throw ex;
            }
            finally
            {
                _DataHelper.Dispose();
            }
        }
Esempio n. 27
0
        public DatabaseResponse GetAdminUserPermissionsByToken(string token)
        {
            try
            {
                SqlParameter[] parameters =
                {
                    new SqlParameter("@AuthToken", SqlDbType.VarChar),
                };

                parameters[0].Value = token;

                _DataHelper = new DataAccessHelper("Admin_GetPermissionsByToken", parameters, _configuration);

                DataTable dt = new DataTable();

                int result = _DataHelper.Run(dt);

                DatabaseResponse response = new DatabaseResponse();

                if (dt != null && dt.Rows.Count > 0)
                {
                    List <Permission> permissionList = new List <Permission>();

                    permissionList = (from model in dt.AsEnumerable()
                                      select new Permission()
                    {
                        RolePermission = model.Field <string>("Permission"),
                    }).ToList();


                    List <string> permissions = permissionList.Select(item => item.RolePermission).ToList();

                    response = new DatabaseResponse {
                        ResponseCode = result, Results = permissions
                    };
                }

                else
                {
                    response = new DatabaseResponse {
                        ResponseCode = result
                    }
                };

                return(response);
            }
            catch (Exception ex)
            {
                LogInfo.Error(new ExceptionHelper().GetLogString(ex, ErrorLevel.Critical));

                throw ex;
            }
            finally
            {
                _DataHelper.Dispose();
            }
        }
Esempio n. 28
0
        public async Task <DatabaseResponse> CreateAdminUser(RegisterAdminUser adminuser, int AdminUserID)
        {
            try
            {
                SqlParameter[] parameters =
                {
                    new SqlParameter("@FullName",  SqlDbType.NVarChar),
                    new SqlParameter("@Email",     SqlDbType.NVarChar),
                    new SqlParameter("@Password",  SqlDbType.NVarChar),
                    new SqlParameter("@RoleID",    SqlDbType.Int),
                    new SqlParameter("@CreatedBy", SqlDbType.Int)
                };

                parameters[0].Value = adminuser.FullName;
                parameters[1].Value = adminuser.Email;
                parameters[2].Value = new Sha2().Hash(adminuser.Password);
                parameters[3].Value = adminuser.RoleID;
                parameters[4].Value = AdminUserID;

                _DataHelper = new DataAccessHelper("Admin_CreateAdminUser", parameters, _configuration);

                DataTable dt = new DataTable();

                int result = await _DataHelper.RunAsync(dt);

                AdminUsers newCustomer = new AdminUsers();

                if (dt != null && dt.Rows.Count > 0)
                {
                    newCustomer = (from model in dt.AsEnumerable()
                                   select new AdminUsers()
                    {
                        AdminUserID = model.Field <int>("AdminUserID"),
                        Email = model.Field <string>("Email"),
                        Password = model.Field <string>("Password"),
                        Name = model.Field <string>("Name"),
                        Role = model.Field <string>("Role"),
                    }).FirstOrDefault();
                }

                return(new DatabaseResponse {
                    ResponseCode = result, Results = adminuser
                });
            }

            catch (Exception ex)
            {
                LogInfo.Error(new ExceptionHelper().GetLogString(ex, ErrorLevel.Critical));

                throw (ex);
            }
            finally
            {
                _DataHelper.Dispose();
            }
        }
Esempio n. 29
0
        /// <summary>
        /// Changes the request offset voucher.
        /// </summary>
        /// <param name="SubscriberID">The subscriber identifier.</param>
        /// <param name="AdminUserID">The admin user identifier.</param>
        /// <returns></returns>
        public async Task <DatabaseResponse> ChangeRequestOffsetVoucher(int SubscriberID, int AdminUserID)
        {
            try
            {
                SqlParameter[] parameters =
                {
                    new SqlParameter("@SubscriberID", SqlDbType.Int),
                    new SqlParameter("@AdminUserID",  SqlDbType.Int)
                };

                parameters[0].Value = SubscriberID;
                parameters[1].Value = AdminUserID;

                _DataHelper = new DataAccessHelper(DbObjectNames.Admin_AssignChangeRequestOffsetVoucher, parameters, _configuration);

                int result = await _DataHelper.RunAsync(); // 105 /102

                DatabaseResponse response = new DatabaseResponse();

                if (result == (int)DbReturnValue.RecordExists)
                {
                    response = new DatabaseResponse {
                        ResponseCode = result, Results = "voucher has been assigned for selected subscriber"
                    };
                }
                else if (result == (int)DbReturnValue.VoucherNotApplicable_CR)
                {
                    response = new DatabaseResponse {
                        ResponseCode = result, Results = DbReturnValue.VoucherNotApplicable_CR.GetDescription()
                    };
                }
                else if (result == (int)DbReturnValue.ExistingVoucher)
                {
                    response = new DatabaseResponse {
                        ResponseCode = result, Results = DbReturnValue.ExistingVoucher.GetDescription()
                    };
                }
                else
                {
                    response = null;
                }

                return(response);
            }

            catch (Exception ex)
            {
                LogInfo.Error(new ExceptionHelper().GetLogString(ex, ErrorLevel.Critical));

                throw (ex);
            }
            finally
            {
                _DataHelper.Dispose();
            }
        }
Esempio n. 30
0
        /// <summary>
        /// Pushes the messages from message queue table.
        /// </summary>
        /// <returns></returns>
        public async Task PushMessagesFromMessageQueueTable()
        {
            MessageQueueResponse responseData = new MessageQueueResponse();

            try
            {
                //Get 1 first message from table
                responseData = await GetMessageFromMessageQueueTable();

                if (responseData != null)
                {//Push message
                    var pushResult = await PublishMessageToQueue(responseData.Source, responseData.MessageBody, null, responseData.SNSTopic, responseData.MessageAttribute);

                    if (pushResult.Trim().ToUpper() == "OK")
                    {//Update the message queue
                        MessageQueueRequest messageQueueRequest = new MessageQueueRequest();
                        messageQueueRequest.LastTriedOn           = DateTime.Now;
                        messageQueueRequest.MessageQueueRequestID = responseData.MessageQueueRequestID;
                        messageQueueRequest.NumberOfRetries       = responseData.NumberOfRetries + 1;
                        messageQueueRequest.PublishedOn           = DateTime.Now;
                        messageQueueRequest.Status = 1;

                        await UpdateMessageQueueObjectToTable(messageQueueRequest);

                        LogInfo.Information("Ended successfully processing of  MessageQueueRequestID =  " + responseData.MessageQueueRequestID);
                    }
                    else
                    {
                        MessageQueueRequest messageQueueRequest = new MessageQueueRequest();
                        messageQueueRequest.LastTriedOn           = DateTime.Now;
                        messageQueueRequest.MessageQueueRequestID = responseData.MessageQueueRequestID;
                        messageQueueRequest.NumberOfRetries       = responseData.NumberOfRetries + 1;
                        messageQueueRequest.PublishedOn           = responseData.PublishedOn;
                        messageQueueRequest.Status = 0;

                        await UpdateMessageQueueObjectToTable(messageQueueRequest);

                        LogInfo.Information("Ended Unsuccessfully processing of  MessageQueueRequestID =  " + responseData.MessageQueueRequestID);
                    }
                }
            }
            catch (Exception ex)
            {
                LogInfo.Error(new ExceptionHelper().GetLogString(ex, ErrorLevel.Critical));
                MessageQueueRequest messageQueueRequest = new MessageQueueRequest();
                messageQueueRequest.LastTriedOn           = DateTime.Now;
                messageQueueRequest.MessageQueueRequestID = responseData.MessageQueueRequestID;
                messageQueueRequest.NumberOfRetries       = responseData.NumberOfRetries + 1;
                messageQueueRequest.PublishedOn           = responseData.PublishedOn;
                messageQueueRequest.Status = 0;

                await UpdateMessageQueueObjectToTable(messageQueueRequest);

                throw ex;
            }
        }