Beispiel #1
0
 LoyaltyResponse UploadInvoiceTransactionToCloud(string inSyndicateCode, ApiMemberInvoiceTransactionViewModel transaction)
 {
     try
     {
         ILoyaltymateService loyaltymateService = new LoyaltymateService();
         var response = loyaltymateService.PostInvoiceTransaction(transaction, inSyndicateCode);
         if (response)
         {
             return(CreateResponseNoError());
         }
         else
         {
             return(CreateResponseError(
                        "@Failed to post member transaction to server",
                        "",
                        LoyaltyResponseCode.PostTransactionFailed));
         }
     }
     catch (AuthenticationFailedException ex)
     {
         return(CreateResponseError(
                    @"Failed to Authenticate",
                    ex.Message,
                    LoyaltyResponseCode.AuthenticationFailed));
     }
     catch (Exception ex)
     {
         return(CreateResponseError(
                    "@Failed to post member transaction to server",
                    ex.Message,
                    LoyaltyResponseCode.PostTransactionFailed));
     }
 }
Beispiel #2
0
 public LoyaltyResponse UpdateMemberCardCode(string inSyndicateCode, string uniqueId, string memberCardCode)
 {
     try
     {
         ILoyaltymateService loyaltymateService = new LoyaltymateService();
         var response = loyaltymateService.UpdateMemberCardCode(inSyndicateCode, uniqueId, memberCardCode);
         if (response)
         {
             return(CreateResponseNoError());
         }
         else
         {
             return(CreateResponseError(
                        "@Failed to update member information to server",
                        "",
                        LoyaltyResponseCode.UpdateMemberFailed));
         }
     }
     catch (AuthenticationFailedException ex)
     {
         return(CreateResponseError(
                    @"Failed to Authenticate",
                    ex.Message,
                    LoyaltyResponseCode.AuthenticationFailed));
     }
     catch (Exception ex)
     {
         return(CreateResponseError(
                    "@Failed to update member information to server",
                    ex.Message,
                    LoyaltyResponseCode.UpdateMemberFailed));
     }
 }
Beispiel #3
0
 private LoyaltyVoucherResponse GetPocketVoucherDetailFromCloud(string inSyndicateCode, RequestInfo requestInfo)
 {
     try
     {
         ILoyaltymateService loyaltymateService = new LoyaltymateService();
         var response = loyaltymateService.GetPocketVoucherDetail(inSyndicateCode, CreateRequest(requestInfo));
         return(CreateVoucherResponseNoError(CreateVoucherInfo(response)));
     }
     catch (AuthenticationFailedException ex)
     {
         return(CreateVoucherResponseError(
                    @"Failed to Authenticate",
                    ex.Message,
                    LoyaltyResponseCode.AuthenticationFailed, new VoucherInfo()));
     }
     catch (LoyaltymateOperationException ex)
     {
         return(CreateVoucherResponseError(ex.Message, @"Invalid Pocket Voucher Number",
                                           LoyaltyResponseCode.InvalidPocketVoucher, new VoucherInfo()));
     }
     catch (Exception exc)
     {
         return(CreateVoucherResponseError(@"Failed to request voucher detail from the server",
                                           exc.Message,
                                           LoyaltyResponseCode.GetPocketVoucherFailed,
                                           new VoucherInfo()));
     }
 }
Beispiel #4
0
 private LoyaltyMemberResponse GetMemberByEmailFromCloud(string inSyndicateCode, RequestInfo requestInfo)
 {
     try
     {
         ILoyaltymateService loyaltymateService = new LoyaltymateService();
         var response = loyaltymateService.GetMemberByEmail(CreateRequest(requestInfo), inSyndicateCode);
         return(CreateMemberResponseNoError(createMemberInfo(response)));
     }
     catch (AuthenticationFailedException ex)
     {
         return(CreateMemberResponseError(
                    @"Failed to Authenticate",
                    ex.Message,
                    LoyaltyResponseCode.AuthenticationFailed,
                    new MemberInfo()
         {
             MemberCardCode = requestInfo.RequestKey
         }));
     }
     catch (Exception exc)
     {
         return(CreateMemberResponseError(@"Failed to request member's info from the Cloud",
                                          exc.Message,
                                          LoyaltyResponseCode.GetMemberFailed,
                                          CreateMemberInfoByEmail(requestInfo.RequestKey)));
     }
 }
Beispiel #5
0
 LoyaltyMemberResponse CreateMemberInTheCloud(string inSyndicateCode, MemberInfo inInfo)
 {
     try
     {
         ILoyaltymateService loyaltymateService = new LoyaltymateService();
         var response = loyaltymateService.SaveMember(CreateMemberObject(inInfo), inSyndicateCode);
         return(CreateMemberResponseNoError(createMemberInfo(response)));
     }
     catch (AuthenticationFailedException ex)
     {
         return(CreateMemberResponseError(
                    @"Failed to Authenticate",
                    ex.Message,
                    LoyaltyResponseCode.AuthenticationFailed,
                    inInfo));
     }
     catch (Exception exc)
     {
         return(CreateMemberResponseError(
                    @"Failed to create a member in the server",
                    exc.Message,
                    LoyaltyResponseCode.CreateMemberFailed,
                    CreateMemberInfo(@"")));
     }
 }
Beispiel #6
0
 private LoyaltyGiftCardResponse GetGiftCardBalanceFromCloud(string inSyndicateCode, RequestInfo requestInfo)
 {
     try
     {
         ILoyaltymateService loyaltymateService = new LoyaltymateService();
         var response = loyaltymateService.GetGiftCardBalance(inSyndicateCode, CreateRequest(requestInfo));
         return(CreateGiftCardResponseNoError(response));
     }
     catch (AuthenticationFailedException ex)
     {
         return(CreateGiftCardResponseError(
                    @"Failed to Authenticate",
                    ex.Message,
                    LoyaltyResponseCode.AuthenticationFailed, 0));
     }
     catch (LoyaltymateOperationException ex)
     {
         return(CreateGiftCardResponseError(ex.Message,
                                            @"Invalid Gift Voucher Number",
                                            LoyaltyResponseCode.InvalidGiftVoucher, 0));
     }
     catch (Exception exc)
     {
         return(CreateGiftCardResponseError(
                    @"Failed to request gift card balance from the server",
                    exc.Message,
                    LoyaltyResponseCode.GetGiftCardFailed,
                    0));
     }
 }
Beispiel #7
0
 public LoyaltyResponse ReleaseVouchersInCloud(string inSyndicateCode, ReleasedVoucherInfo releasedVoucherInfo)
 {
     try
     {
         ILoyaltymateService loyaltymateService = new LoyaltymateService();
         var response = loyaltymateService.ReleaseVouchers(inSyndicateCode, CreateReleasedVoucherTransaction(releasedVoucherInfo));
         if (response)
         {
             return(CreateResponseNoError());
         }
         else
         {
             return(CreateResponseError(
                        "@Failed to process vouchers",
                        "",
                        LoyaltyResponseCode.PostTransactionFailed));
         }
     }
     catch (AuthenticationFailedException ex)
     {
         return(CreateResponseError(
                    @"Failed to Authenticate",
                    ex.Message,
                    LoyaltyResponseCode.AuthenticationFailed));
     }
     catch (Exception ex)
     {
         return(CreateResponseError(
                    "@Failed to process vouchers",
                    ex.Message,
                    LoyaltyResponseCode.PostTransactionFailed));
     }
 }
Beispiel #8
0
 LoyaltyMemberResponse GetMemberByCodeFromCloud(string inSyndicateCode, RequestInfo requestInfo)
 {
     try
     {
         ILoyaltymateService loyaltymateService = new LoyaltymateService();
         var response = loyaltymateService.GetMemberByCardCode(CreateRequest(requestInfo), inSyndicateCode);
         return(CreateMemberResponseNoError(createMemberInfo(response)));
     }
     catch (LoyaltymateOperationException ex)
     {
         if (ex.Message.Contains("Member Not"))
         {
             return(CreateMemberResponseError(ex.Message,
                                              @"Member Not Exist.",
                                              LoyaltyResponseCode.MemberNotExist,
                                              new MemberInfo()
             {
                 MemberCardCode = requestInfo.RequestKey
             }));
         }
         else
         {
             return(CreateMemberResponseError(ex.Message,
                                              @"Loyaltymate error.",
                                              LoyaltyResponseCode.GetMemberFailed,
                                              new MemberInfo()
             {
                 MemberCardCode = requestInfo.RequestKey
             }));
         }
     }
     catch (AuthenticationFailedException ex)
     {
         return(CreateMemberResponseError(
                    @"Failed to Authenticate",
                    ex.Message,
                    LoyaltyResponseCode.AuthenticationFailed,
                    new MemberInfo()
         {
             MemberCardCode = requestInfo.RequestKey
         }));
     }
     catch (Exception exc)
     {
         return(CreateMemberResponseError(@"Failed to request member's info from the server",
                                          exc.Message,
                                          LoyaltyResponseCode.GetMemberFailed,
                                          CreateMemberInfoByCode(requestInfo.RequestKey)));
     }
 }
Beispiel #9
0
 LoyaltyResponse DeleteTierFromTheCloud(string inSyndicateCode, int tierLevelId)
 {
     try
     {
         ILoyaltymateService loyaltymateService = new LoyaltymateService();
         var response = loyaltymateService.DeleteTierLevel(tierLevelId, inSyndicateCode);
         return(CreateResponseNoError());
     }
     catch (AuthenticationFailedException ex)
     {
         return(CreateResponseError(
                    @"Failed to Authenticate",
                    ex.Message,
                    LoyaltyResponseCode.AuthenticationFailed));
     }
     catch (Exception exc)
     {
         return(CreateResponseError(@"Failed to delete a tier from the Cloud", exc.Message,
                                    LoyaltyResponseCode.DeleteTierFailed));
     }
 }
Beispiel #10
0
 private LoyaltyResponse PostVoucherTransaction(string inSyndicateCode, VoucherTransactionInfo transaction)
 {
     try
     {
         ILoyaltymateService loyaltymateService = new LoyaltymateService();
         var response = loyaltymateService.PostVoucherTransactions(inSyndicateCode, CreateVoucherTransaction(transaction));
         if (response != null)
         {
             foreach (var item in response)
             {
                 if (!item.IsProcessedSuccessfully)
                 {
                     return(CreateResponseError(item.Error,
                                                item.Error,
                                                LoyaltyResponseCode.PostTransactionFailed));
                 }
             }
             return(CreateResponseNoError());
         }
         return(CreateResponseError(
                    @"Failed to process vouchers",
                    @"Failed to process vouchers",
                    LoyaltyResponseCode.PostTransactionFailed));
     }
     catch (AuthenticationFailedException ex)
     {
         return(CreateResponseError(
                    @"Failed to Authenticate",
                    ex.Message,
                    LoyaltyResponseCode.AuthenticationFailed));
     }
     catch (Exception ex)
     {
         return(CreateResponseError(
                    "@Failed to post transaction to server",
                    ex.Message,
                    LoyaltyResponseCode.PostTransactionFailed));
     }
 }
Beispiel #11
0
 LoyaltyCompanyResponse GetCompanyInformationFromCloud(string inSyndicateCode)
 {
     try
     {
         ILoyaltymateService loyaltymateService = new LoyaltymateService();
         var response = loyaltymateService.GetCompanyDetail(inSyndicateCode);
         return(CreateCompanyResponseNoError(CreateCompanyInfo(response)));
     }
     catch (AuthenticationFailedException ex)
     {
         return(CreateCompanyResponseError(
                    @"Failed to Authenticate",
                    ex.Message,
                    LoyaltyResponseCode.AuthenticationFailed, new CompanyInfo()));
     }
     catch (Exception exc)
     {
         return(CreateCompanyResponseError(
                    @"Unable to sync with server",
                    exc.Message,
                    LoyaltyResponseCode.CompanySyncFailed,
                    new CompanyInfo()));
     }
 }
Beispiel #12
0
 LoyaltyTierListResponse GetAllTierLevelFromCloud(string inSyndicateCode)
 {
     try
     {
         ILoyaltymateService loyaltymateService = new LoyaltymateService();
         var response = loyaltymateService.GetAllTierLevels(inSyndicateCode);
         return(CreateTierListResponseNoError(CreateTierLevelInfoList(response)));
     }
     catch (AuthenticationFailedException ex)
     {
         return(CreateTierListResponseError(
                    @"Failed to Authenticate",
                    ex.Message,
                    LoyaltyResponseCode.AuthenticationFailed, new List <TierLevelInfo>()));
     }
     catch (Exception exc)
     {
         return(CreateTierListResponseError(
                    @"Failed to request tier's info from the Cloud",
                    exc.Message,
                    LoyaltyResponseCode.DeleteTierFailed,
                    new List <TierLevelInfo>()));
     }
 }
Beispiel #13
0
 LoyaltyTierResponse GetTierFromTheCloud(string inSyndicateCode, int tierId)
 {
     try
     {
         ILoyaltymateService loyaltymateService = new LoyaltymateService();
         var response = loyaltymateService.GetTierLevel(tierId, inSyndicateCode);
         return(CreateTierResponseNoError(CreateTierInfo(response)));
     }
     catch (AuthenticationFailedException ex)
     {
         return(CreateTierResponseError(
                    @"Failed to Authenticate",
                    ex.Message,
                    LoyaltyResponseCode.AuthenticationFailed, CreateTierInfo(tierId)));
     }
     catch (Exception exc)
     {
         return(CreateTierResponseError(
                    @"Failed to request tier's info from the Cloud",
                    exc.Message,
                    LoyaltyResponseCode.DeleteTierFailed,
                    CreateTierInfo(tierId)));
     }
 }