示例#1
0
 public Entity.SaveCompanyResponse CreateCompany(Entity.SaveCompanyRequest requestData)
 {
     InitSubscriptionToken();
     Entity.SubsciberCompanyDetails existingConsumer = GetSubscriberDetails(requestData.SolutionCode, requestData.User.Email);
     if (existingConsumer != null && string.IsNullOrEmpty(existingConsumer.email))//Check email exists or not
     {
         using (var response = _httpClientHelper.Post <Entity.SaveCompanyRequest>(string.Concat(apiBaseURL, "solution/company"), requestData, _subcriptionAccessToken))
         {
             if ((int)response.StatusCode == (int)HttpStatusCode.OK)
             {
                 return(JsonConvert.DeserializeObject <Entity.SaveCompanyResponse>(response.Content.ReadAsStringAsync().Result));
             }
             else
             {
                 List <Entity.ErrorMessageResponse> errorMessage = JsonConvert.DeserializeObject <List <Entity.ErrorMessageResponse> >(response.Content.ReadAsStringAsync().Result);
                 if (errorMessage != null && errorMessage.Any())
                 {
                     throw new Exception(string.Format("{0}", errorMessage.FirstOrDefault().msg));
                 }
                 else
                 {
                     throw new Exception("Please try again. Something went wrong!!!");
                 }
             }
         }
     }
     else
     {
         throw new Exception("Email address already registered. Try with another email!!!");
     }
 }
示例#2
0
        public Entity.BaseResponse <bool> ValidateCompany(Entity.ValidateCompanyRequest requestData)
        {
            InitSubscriptionToken();
            Entity.BaseResponse <bool> response = new Entity.BaseResponse <bool>(false);
            //bool IsCompanyExists = false;
            bool IsEmailExists = false;

            if (!string.IsNullOrEmpty(requestData.Email))
            {
                Entity.SubsciberCompanyDetails existingConsumer = GetSubscriberDetails(SolutionConfiguration.Configuration.SubscriptionAPI.SolutionCode, requestData.Email);
                if (existingConsumer != null && string.IsNullOrEmpty(existingConsumer.email))//Check email exists or not
                {
                    IsEmailExists = false;
                }
                else
                {
                    IsEmailExists = true;
                }
            }
            //if (!string.IsNullOrEmpty(requestData.CompanyName))
            //{
            //    if (GetCompanyDetails(SolutionConfiguration.Configuration.SubscriptionAPI.SolutionCode, requestData.CompanyName))
            //    {
            //        IsCompanyExists = false;
            //    }
            //    else
            //    {
            //        IsCompanyExists = true;
            //    }
            //}
            if (IsEmailExists)
            {
                response.IsSuccess = false;
                response.Message   = "Email address already registered!";
            }
            //else if (IsCompanyExists)
            //{
            //    response.IsSuccess = false;
            //    response.Message = "Company name already registered!";
            //}
            //else if (IsEmailExists)
            //{
            //    response.IsSuccess = false;
            //    response.Message = "Email address already registered!";
            //}
            else
            {
                response.IsSuccess = true;
                response.Message   = "";
            }
            return(response);
        }
 public Entity.SubsciberCompanyDetails GetSubscriberDetails(string solutionCode, string userEmail)
 {
     Entity.SubsciberCompanyDetails result = new Entity.SubsciberCompanyDetails();
     try
     {
         result = _subscriberHelper.GetSubscriberDetails(solutionCode, userEmail);
     }
     catch (Exception ex)
     {
         _logger.ErrorLog(ex, this.GetType().Name, MethodBase.GetCurrentMethod().Name);
     }
     return(result);
 }
示例#4
0
 public Entity.SubsciberCompanyDetails GetSubscriberDetails(string solutionCode, string userEmail)
 {
     Entity.SubsciberCompanyDetails result = new Entity.SubsciberCompanyDetails();
     try
     {
         result = _httpClientHelper.Get <Entity.SubsciberCompanyDetails>(string.Format("{0}subscriber/{1}/{2}/consumption/active", apiBaseURL, solutionCode, userEmail), _subcriptionAccessToken);
     }
     catch (Exception ex)
     {
         _logger.ErrorLog(ex, this.GetType().Name, MethodBase.GetCurrentMethod().Name);
     }
     return(result);
 }