Beispiel #1
0
        public static ResponseBoats GetBoatInfo(long boatId)
        {
            try
            {
                Boats boat = boatsService.SelectByBoatId(boatId);
                GetCaptainInfo(boat.CAPTAIN_ID);

                ResponseBoats response = new ResponseBoats
                {
                    BOAT_ID     = boat.BOAT_ID,
                    BOAT_INFO   = boat.BOAT_INFO,
                    BOAT_NAME   = boat.BOAT_NAME,
                    FLAG        = boat.FLAG,
                    ROTA_INFO   = boat.ROTA_INFO,
                    CAPTAIN_ID  = boat.CAPTAIN_ID,
                    QUANTITY    = boat.QUANTITY,
                    REGION_ID   = boat.REGION_ID,
                    REGION_NAME = GetRegionName(boat.REGION_ID),
                    header      = new ResponseHeader
                    {
                        IsSuccess       = true,
                        ResponseCode    = CommonDefinitions.SUCCESS,
                        ResponseMessage = CommonDefinitions.SUCCESS_MESSAGE
                    }
                };

                return(response);
            }
            catch (Exception ex)
            {
                log.Error("An unexpected error occured while getting customer informations");
                throw ex;
            }
        }
Beispiel #2
0
        public List <ResponseBoats> SelectPopularBoats()
        {
            Boats boat = null;
            List <ResponseBoats>        _favorite     = new List <ResponseBoats>();
            List <ResponsePopularBoats> respFavorites = new List <ResponsePopularBoats>();

            using (var sqlConnection = new SqlConnection(Constant.DatabaseConnection))
            {
                sqlConnection.Open();
                IEnumerable <ResponsePopularBoats> favorite = sqlConnection.Query <ResponsePopularBoats>("select distinct (BOAT_ID) as BoatId , COUNT(*) OVER (PARTITION BY BOAT_ID) AS Count from FAVORITES(NOLOCK) where  RECORD_STATUS = 1  order by Count desc");

                if (favorite.Count() == 0)
                {
                    throw new Exception(CommonDefinitions.BOAT_NOT_FOUND);
                }
                else
                {
                    respFavorites = favorite.ToList();
                }

                //Most popular 3 boat informations
                for (int i = 0; i < 3; i++)
                {
                    if (i < respFavorites.Count())
                    {
                        boat = new Boats();
                        boat = boatsService.SelectByBoatId(respFavorites[i].BoatId);
                        ResponseBoats response = new ResponseBoats
                        {
                            INSERT_USER   = boat.INSERT_USER,
                            UPDATE_USER   = boat.UPDATE_USER,
                            BOAT_ID       = boat.BOAT_ID,
                            BOAT_INFO     = boat.BOAT_INFO,
                            BOAT_NAME     = boat.BOAT_NAME,
                            CAPTAIN_ID    = boat.CAPTAIN_ID,
                            FLAG          = boat.FLAG,
                            QUANTITY      = boat.QUANTITY,
                            ROTA_INFO     = boat.ROTA_INFO,
                            REGION_ID     = boat.REGION_ID,
                            REGION_NAME   = regionService.SelectByRegionId(boat.REGION_ID).REGION_NAME,
                            PRICE         = boat.PRICE,
                            PRIVATE_PRICE = boat.PRIVATE_PRICE,
                            TOUR_TYPE     = boat.TOUR_TYPE,
                            header        = new Dto.ResponseHeader
                            {
                                IsSuccess       = true,
                                ResponseCode    = CommonDefinitions.SUCCESS,
                                ResponseMessage = CommonDefinitions.SUCCESS_MESSAGE,
                            }
                        };
                        _favorite.Add(response);
                    }
                }
                return(_favorite);
            }
        }
Beispiel #3
0
        public override void DoOperation()
        {
            try
            {
                //Validate Reques Header / Constants
                this.baseResponseMessage = ValidateInput();
                if (!this.baseResponseMessage.header.IsSuccess)
                {
                    throw new Exception(this.baseResponseMessage.header.ResponseMessage);
                }

                switch (this.request.Header.OperationTypes)
                {
                case (int)OperationType.OperationTypes.ADD:
                    #region Add
                    long checkGuid = 0;
                    this.boat = new Boats
                    {
                        INSERT_USER   = this.request.INSERT_USER,
                        UPDATE_USER   = this.request.UPDATE_USER,
                        BOAT_INFO     = this.request.BOAT_INFO,
                        BOAT_NAME     = this.request.BOAT_NAME,
                        CAPTAIN_ID    = this.request.CAPTAIN_ID,
                        FLAG          = this.request.FLAG,
                        QUANTITY      = this.request.QUANTITY,
                        ROTA_INFO     = this.request.ROTA_INFO,
                        REGION_ID     = this.request.REGION_ID,
                        PRICE         = this.request.PRICE,
                        PRIVATE_PRICE = this.request.PRIVATE_PRICE,
                        TOUR_TYPE     = this.request.TOUR_TYPE
                    };

                    checkGuid = Boats.Insert(this.boat);

                    this.response = new ResponseBoats
                    {
                        INSERT_USER   = this.boat.INSERT_USER,
                        UPDATE_USER   = this.boat.UPDATE_USER,
                        BOAT_ID       = this.boat.BOAT_ID,
                        BOAT_INFO     = this.boat.BOAT_INFO,
                        BOAT_NAME     = this.boat.BOAT_NAME,
                        CAPTAIN_ID    = this.request.CAPTAIN_ID,
                        FLAG          = this.request.FLAG,
                        QUANTITY      = this.request.QUANTITY,
                        ROTA_INFO     = this.request.ROTA_INFO,
                        REGION_ID     = this.request.REGION_ID,
                        REGION_NAME   = CommonServices.GetRegionName(this.request.REGION_ID),
                        PRICE         = this.request.PRICE,
                        PRIVATE_PRICE = this.request.PRIVATE_PRICE,
                        TOUR_TYPE     = this.request.TOUR_TYPE,
                        header        = new ResponseHeader
                        {
                            IsSuccess       = checkGuid == 0 ? false : true,
                            ResponseCode    = checkGuid == 0 ? CommonDefinitions.INTERNAL_SYSTEM_UNKNOWN_ERROR : CommonDefinitions.SUCCESS,
                            ResponseMessage = checkGuid == 0 ? CommonDefinitions.ERROR_MESSAGE : CommonDefinitions.SUCCESS_MESSAGE
                        }
                    };
                    #endregion
                    break;

                case (int)OperationType.OperationTypes.GET:
                    #region GET
                    //Bölgesel Arama
                    if (this.request.REGION_ID != 0)
                    {
                        this.listboat = Boats.SelectByRegionId(this.request.REGION_ID);
                        if (listboat != null && listboat.Count > 0)
                        {
                            foreach (var item in listboat)
                            {
                                this.response = new ResponseBoats
                                {
                                    INSERT_USER = item.INSERT_USER,
                                    UPDATE_USER = item.UPDATE_USER,
                                    BOAT_ID     = item.BOAT_ID,
                                    BOAT_INFO   = item.BOAT_INFO,
                                    BOAT_NAME   = item.BOAT_NAME,
                                    CAPTAIN_ID  = item.CAPTAIN_ID,
                                    FLAG        = item.FLAG,
                                    QUANTITY    = item.QUANTITY,
                                    ROTA_INFO   = item.ROTA_INFO,
                                    REGION_ID   = item.REGION_ID,
                                    REGION_NAME = CommonServices.GetRegionName(this.request.REGION_ID),
                                    header      = new ResponseHeader
                                    {
                                        IsSuccess       = true,
                                        ResponseCode    = CommonDefinitions.SUCCESS,
                                        ResponseMessage = CommonDefinitions.SUCCESS_MESSAGE
                                    }
                                };
                                reponseAllBoats.Add(this.response);
                            }
                            this.response.AllBoats = reponseAllBoats;
                        }
                    }
                    else
                    {
                        //Tekli Arama
                        this.boat = Boats.SelectByBoatId(this.request.BOAT_ID);

                        this.response = new ResponseBoats
                        {
                            INSERT_USER = this.boat.INSERT_USER,
                            UPDATE_USER = this.boat.UPDATE_USER,
                            BOAT_ID     = this.boat.BOAT_ID,
                            BOAT_INFO   = this.boat.BOAT_INFO,
                            BOAT_NAME   = this.boat.BOAT_NAME,
                            CAPTAIN_ID  = this.boat.CAPTAIN_ID,
                            FLAG        = this.boat.FLAG,
                            QUANTITY    = this.boat.QUANTITY,
                            ROTA_INFO   = this.boat.ROTA_INFO,
                            REGION_ID   = this.boat.REGION_ID,
                            REGION_NAME = CommonServices.GetRegionName(this.request.REGION_ID),
                            header      = new ResponseHeader
                            {
                                IsSuccess       = true,
                                ResponseCode    = CommonDefinitions.SUCCESS,
                                ResponseMessage = CommonDefinitions.SUCCESS_MESSAGE
                            }
                        };
                    }
                    #endregion
                    break;

                case (int)OperationType.OperationTypes.UPDATE:
                    #region  Update
                    this.boat = new Boats
                    {
                        BOAT_ID       = this.request.BOAT_ID,
                        INSERT_USER   = this.request.INSERT_USER,
                        UPDATE_USER   = this.request.UPDATE_USER,
                        BOAT_INFO     = this.request.BOAT_INFO,
                        BOAT_NAME     = this.request.BOAT_NAME,
                        CAPTAIN_ID    = this.request.CAPTAIN_ID,
                        FLAG          = this.request.FLAG,
                        QUANTITY      = this.request.QUANTITY,
                        ROTA_INFO     = this.request.ROTA_INFO,
                        REGION_ID     = this.request.REGION_ID,
                        PRICE         = this.request.PRICE,
                        PRIVATE_PRICE = this.request.PRIVATE_PRICE,
                        TOUR_TYPE     = this.request.TOUR_TYPE
                    };

                    Boats.Update(this.boat);

                    this.response = new ResponseBoats
                    {
                        INSERT_USER = this.boat.INSERT_USER,
                        UPDATE_USER = this.boat.UPDATE_USER,
                        BOAT_ID     = this.boat.BOAT_ID,
                        BOAT_INFO   = this.boat.BOAT_INFO,
                        BOAT_NAME   = this.boat.BOAT_NAME,
                        CAPTAIN_ID  = this.boat.CAPTAIN_ID,
                        FLAG        = this.boat.FLAG,
                        QUANTITY    = this.boat.QUANTITY,
                        ROTA_INFO   = this.boat.ROTA_INFO,
                        REGION_ID   = this.boat.REGION_ID,
                        REGION_NAME = CommonServices.GetRegionName(this.request.REGION_ID),
                        header      = new ResponseHeader
                        {
                            IsSuccess       = true,
                            ResponseCode    = CommonDefinitions.SUCCESS,
                            ResponseMessage = CommonDefinitions.SUCCESS_MESSAGE
                        }
                    };
                    #endregion
                    break;

                case (int)OperationType.OperationTypes.DELETE:
                    #region DELETE
                    this.boat = new Boats
                    {
                        INSERT_USER = this.request.INSERT_USER,
                        UPDATE_USER = this.request.UPDATE_USER,
                        BOAT_INFO   = this.request.BOAT_INFO,
                        BOAT_NAME   = this.request.BOAT_NAME,
                        CAPTAIN_ID  = this.request.CAPTAIN_ID,
                        FLAG        = this.request.FLAG,
                        QUANTITY    = this.request.QUANTITY,
                        ROTA_INFO   = this.request.ROTA_INFO,
                        REGION_ID   = this.request.REGION_ID
                    };

                    Boats.Delete(this.boat);
                    this.response = new ResponseBoats
                    {
                        INSERT_USER = this.boat.INSERT_USER,
                        UPDATE_USER = this.boat.UPDATE_USER,
                        BOAT_ID     = this.boat.BOAT_ID,
                        BOAT_INFO   = this.boat.BOAT_INFO,
                        BOAT_NAME   = this.boat.BOAT_NAME,
                        CAPTAIN_ID  = this.boat.CAPTAIN_ID,
                        FLAG        = this.boat.FLAG,
                        QUANTITY    = this.boat.QUANTITY,
                        ROTA_INFO   = this.boat.ROTA_INFO,
                        REGION_ID   = this.boat.REGION_ID,
                        REGION_NAME = CommonServices.GetRegionName(this.request.REGION_ID),
                        header      = new ResponseHeader
                        {
                            IsSuccess       = true,
                            ResponseCode    = CommonDefinitions.SUCCESS,
                            ResponseMessage = CommonDefinitions.SUCCESS_MESSAGE
                        }
                    };
                    #endregion
                    break;

                default:
                    break;
                }
            }
            catch (Exception ex)
            {
                string operationError = "HATA:[" + "BoatId:" + this.request.BOAT_ID + ",ResponseCode:" + this.baseResponseMessage.header.ResponseCode + ", ResponseMessage:" + ex.Message + "]";
                log.InfoFormat(operationError, ex);
                throw new Exception(ex.Message, ex.InnerException);
            }
        }
Beispiel #4
0
        private CreatePaymentRequest Prepare3DRequest(ref Options baseHeader)
        {
            try
            {
                ResponsePersonalInformation responseCustomer        = CommonServices.GetCustomer(this.request.CUSTOMER_NUMBER);
                ResponseCustomerAddress     responseCustomerAddress = CommonServices.GetCustomerAddress(this.request.CUSTOMER_NUMBER);
                ResponseBoats responseBoat = CommonServices.GetBoatInfo(this.request.BOAT_ID);

                baseHeader           = new Options();
                baseHeader.ApiKey    = this.request.ApiKey;    // "sandbox-lJr5mWuuVSnwTa5Dt8bE6ohOi6chI463";
                baseHeader.SecretKey = this.request.SecretKey; // "sandbox-yLkfxt1paeOWTZjV7qzn3rwyFPRrC6Cj";
                baseHeader.BaseUrl   = this.request.BaseUrl;   // "https://sandbox-merchant.iyzipay.com";

                CreatePaymentRequest paymentRequest = new CreatePaymentRequest();
                paymentRequest.Locale         = Locale.TR.ToString();
                paymentRequest.ConversationId = this.request.CONVERSATION_ID;
                paymentRequest.Price          = this.request.PRICE;
                paymentRequest.PaidPrice      = this.request.PAID_PRICE;
                paymentRequest.Currency       = Iyzipay.Model.Currency.TRY.ToString();
                paymentRequest.Installment    = 1;
                paymentRequest.BasketId       = GenerateNumberManager.GenerateBasketId();
                paymentRequest.PaymentChannel = PaymentChannel.WEB.ToString();
                paymentRequest.PaymentGroup   = PaymentGroup.PRODUCT.ToString();
                paymentRequest.CallbackUrl    = "https://www.merchant.com/callback";

                paymentRequest.Buyer = new Iyzipay.Model.Buyer()
                {
                    Id                  = this.request.CUSTOMER_NUMBER.ToString(),
                    Name                = responseCustomer.CUSTOMER_NAME,
                    Surname             = responseCustomer.CUSTOMER_SURNAME,
                    GsmNumber           = responseCustomer.PHONE_NUMBER,
                    Email               = responseCustomer.EMAIL,
                    IdentityNumber      = responseCustomer.IDENTIFICATION_ID.ToString(),
                    LastLoginDate       = DateTime.Now.ToShortDateString(),
                    RegistrationDate    = DateTime.Now.ToShortDateString(),
                    RegistrationAddress = responseCustomerAddress.DESCRIPTION,
                    Ip                  = this.request.IP,
                    City                = responseCustomerAddress.CITY,
                    Country             = responseCustomerAddress.COUNTRY,
                    ZipCode             = responseCustomerAddress.ZIPCODE
                };

                paymentRequest.ShippingAddress = new Iyzipay.Model.Address()
                {
                    ContactName = responseCustomer.CUSTOMER_NAME + " " + responseCustomer.CUSTOMER_SURNAME,
                    City        = responseCustomerAddress.CITY,
                    Country     = responseCustomerAddress.COUNTRY,
                    ZipCode     = responseCustomerAddress.ZIPCODE,
                    Description = responseCustomerAddress.DESCRIPTION
                };

                paymentRequest.BillingAddress = new Iyzipay.Model.Address()
                {
                    ContactName = responseCustomer.CUSTOMER_NAME + " " + responseCustomer.CUSTOMER_SURNAME,
                    City        = responseCustomerAddress.CITY,
                    Country     = responseCustomerAddress.COUNTRY,
                    ZipCode     = responseCustomerAddress.ZIPCODE,
                    Description = responseCustomerAddress.DESCRIPTION
                };

                List <BasketItem> basketItems     = new List <BasketItem>();
                BasketItem        firstBasketItem = new BasketItem();
                firstBasketItem.Id        = paymentRequest.BasketId;//Sepet ID si geliştirilecek
                firstBasketItem.Name      = responseBoat.BOAT_NAME;
                firstBasketItem.Category1 = responseBoat.TOUR_TYPE;
                firstBasketItem.Category2 = Enum.GetName(typeof(Enums.TourType), responseBoat.TOUR_TYPE);
                firstBasketItem.ItemType  = BasketItemType.VIRTUAL.ToString();
                firstBasketItem.Price     = responseBoat.TOUR_TYPE == "1" ? responseBoat.PRICE : responseBoat.PRIVATE_PRICE;
                basketItems.Add(firstBasketItem);

                paymentRequest.BasketItems = basketItems;


                return(paymentRequest);
            }
            catch (Exception)
            {
                throw;
            }
        }
Beispiel #5
0
        private CreatePaymentRequest PrepareRequest(ref bool result, ref string errMsg, ref Options baseHeader, ref string errCode)
        {
            try
            {
                Iyzipay.Request.CreatePaymentRequest paymentRequest   = new Iyzipay.Request.CreatePaymentRequest();
                ResponsePersonalInformation          responseCustomer = CommonServices.GetCustomer(this.request.CUSTOMER_NUMBER);
                ResponseCustomerAddress responseCustomerAddress       = CommonServices.GetCustomerAddress(this.request.CUSTOMER_NUMBER);
                ResponseBoats           responseBoat = CommonServices.GetBoatInfo(this.request.BOAT_ID);

                baseHeader           = new Options();
                baseHeader.ApiKey    = this.request.ApiKey;    // "sandbox-lJr5mWuuVSnwTa5Dt8bE6ohOi6chI463";
                baseHeader.SecretKey = this.request.SecretKey; // "sandbox-yLkfxt1paeOWTZjV7qzn3rwyFPRrC6Cj";
                baseHeader.BaseUrl   = this.request.BaseUrl;   // "https://sandbox-merchant.iyzipay.com";

                string cvc = "";
                if (String.IsNullOrEmpty(this.request.PaymentCard.CARD_CVV))
                {
                    cvc = "000";
                }
                else
                {
                    cvc = this.request.PaymentCard.CARD_CVV;
                }

                paymentRequest.PaymentCard = new Iyzipay.Model.PaymentCard()
                {
                    CardHolderName = this.request.PaymentCard.CARD_HOLDER_NAME,
                    CardNumber     = Common.CipherAlgorithm.Decrypt(this.request.PaymentCard.CARD_REF_NUMBER, CipherAlgorithm.password),
                    ExpireMonth    = this.request.PaymentCard.CARD_EXPIRE_MONTH,
                    ExpireYear     = this.request.PaymentCard.CARD_EXPIRE_YEAR,
                    Cvc            = cvc,
                    RegisterCard   = 0//default
                };


                paymentRequest.Buyer = new Iyzipay.Model.Buyer()
                {
                    Id                  = this.request.CUSTOMER_NUMBER.ToString(),
                    Name                = responseCustomer.CUSTOMER_NAME,
                    Surname             = responseCustomer.CUSTOMER_SURNAME,
                    GsmNumber           = responseCustomer.PHONE_NUMBER,
                    Email               = responseCustomer.EMAIL,
                    IdentityNumber      = responseCustomer.IDENTIFICATION_ID.ToString(),
                    LastLoginDate       = DateTime.Now.ToShortDateString(),
                    RegistrationDate    = DateTime.Now.ToShortDateString(),
                    RegistrationAddress = responseCustomerAddress.DESCRIPTION,
                    Ip                  = this.request.IP,
                    City                = responseCustomerAddress.CITY,
                    Country             = responseCustomerAddress.COUNTRY,
                    ZipCode             = responseCustomerAddress.ZIPCODE
                };

                paymentRequest.ShippingAddress = new Iyzipay.Model.Address()
                {
                    ContactName = responseCustomer.CUSTOMER_NAME + " " + responseCustomer.CUSTOMER_SURNAME,
                    City        = responseCustomerAddress.CITY,
                    Country     = responseCustomerAddress.COUNTRY,
                    ZipCode     = responseCustomerAddress.ZIPCODE,
                    Description = responseCustomerAddress.DESCRIPTION
                };

                paymentRequest.BillingAddress = new Iyzipay.Model.Address()
                {
                    ContactName = responseCustomer.CUSTOMER_NAME + " " + responseCustomer.CUSTOMER_SURNAME,
                    City        = responseCustomerAddress.CITY,
                    Country     = responseCustomerAddress.COUNTRY,
                    ZipCode     = responseCustomerAddress.ZIPCODE,
                    Description = responseCustomerAddress.DESCRIPTION
                };

                List <BasketItem> basketItems     = new List <BasketItem>();
                BasketItem        firstBasketItem = new BasketItem();
                firstBasketItem.Id        = GenerateNumberManager.GenerateBasketId();
                firstBasketItem.Name      = responseBoat.BOAT_NAME;
                firstBasketItem.Category1 = responseBoat.TOUR_TYPE;
                firstBasketItem.Category2 = Enum.GetName(typeof(Enums.TourType), responseBoat.TOUR_TYPE);
                firstBasketItem.ItemType  = BasketItemType.VIRTUAL.ToString();
                firstBasketItem.Price     = responseBoat.TOUR_TYPE == "1" ? responseBoat.PRICE : responseBoat.PRIVATE_PRICE;
                basketItems.Add(firstBasketItem);

                paymentRequest.BasketItems = basketItems;

                paymentRequest.Locale         = Locale.TR.ToString();
                paymentRequest.ConversationId = this.request.CONVERSATION_ID;
                paymentRequest.Price          = this.request.PRICE;
                paymentRequest.PaidPrice      = (Convert.ToDecimal(this.request.PAID_PRICE) / 100).ToString().Replace(',', '.');
                paymentRequest.Installment    = 0;
                paymentRequest.BasketId       = firstBasketItem.Id;//Sepet Id'si.
                paymentRequest.PaymentChannel = this.request.PAYMENT_CHANNEL.ToString();
                paymentRequest.PaymentGroup   = PaymentGroup.PRODUCT.ToString();

                switch (this.request.CURRENCY)
                {
                case "949":
                    paymentRequest.Currency = Iyzipay.Model.Currency.TRY.ToString();
                    break;

                case "840":
                    paymentRequest.Currency = Iyzipay.Model.Currency.USD.ToString();
                    break;

                case "978":
                    paymentRequest.Currency = Iyzipay.Model.Currency.EUR.ToString();
                    break;

                case "826":
                    paymentRequest.Currency = Iyzipay.Model.Currency.GBP.ToString();
                    break;

                case "364":
                    paymentRequest.Currency = Iyzipay.Model.Currency.IRR.ToString();
                    break;

                default:
                    paymentRequest.Currency = "";
                    break;
                }

                if (String.IsNullOrEmpty(paymentRequest.Currency))
                {
                    errCode = CommonDefinitions.INTERNAL_SYSTEM_ERROR;
                    errMsg  = CommonDefinitions.CURRENCY_CODE_IS_NOT_VALID;
                    result  = false;
                    log.Info("iyzico Sale Call.. Error on PrepareRequest. Detail : " + errMsg);
                }
                return(paymentRequest);
            }
            catch (Exception ex)
            {
                log.Error("Prepare payment data has occured an ERROR. [Error: " + ex.Message + "]");
                throw ex;
            }
        }
Beispiel #6
0
        public override void DoOperation()
        {
            try
            {
                //Validate Reques Header / Constants
                this.baseResponseMessage = ValidateInput();
                if (!this.baseResponseMessage.header.IsSuccess)
                {
                    throw new Exception(this.baseResponseMessage.header.ResponseMessage);
                }

                //Operation
                switch (this.request.Header.OperationTypes)
                {
                case (int)OperationType.OperationTypes.ADD:
                    #region ADD
                    long checkGuid = 0;
                    this.favorite = new Favorites
                    {
                        INSERT_USER     = this.request.INSERT_USER,
                        UPDATE_USER     = this.request.UPDATE_USER,
                        CUSTOMER_NUMBER = this.request.CUSTOMER_NUMBER,
                        BOAT_ID         = this.request.BOAT_ID
                    };

                    checkGuid     = Favorites.Insert(this.favorite);
                    this.response = new ResponseFavorites
                    {
                        BOAT_ID         = this.request.BOAT_ID,
                        CUSTOMER_NUMBER = this.favorite.CUSTOMER_NUMBER,
                        header          = new ResponseHeader
                        {
                            IsSuccess       = checkGuid == 0 ? false : true,
                            ResponseCode    = checkGuid == 0 ? CommonDefinitions.INTERNAL_SYSTEM_UNKNOWN_ERROR : CommonDefinitions.SUCCESS,
                            ResponseMessage = checkGuid == 0 ? CommonDefinitions.ERROR_MESSAGE : CommonDefinitions.SUCCESS_MESSAGE
                        }
                    };
                    #endregion
                    break;

                case (int)OperationType.OperationTypes.GET:
                    #region GET
                    listfavorites = Favorites.SelectByCustomerNumber(this.request.CUSTOMER_NUMBER);
                    //Take all favorites for CustomerNumber
                    foreach (var item in listfavorites)
                    {
                        this.response = new ResponseFavorites
                        {
                            CUSTOMER_NUMBER = item.CUSTOMER_NUMBER,
                            BOAT_ID         = item.BOAT_ID,
                            header          = new ResponseHeader
                            {
                                IsSuccess       = true,
                                ResponseCode    = CommonDefinitions.SUCCESS,
                                ResponseMessage = CommonDefinitions.SUCCESS_MESSAGE
                            }
                        };
                        responseAllFavorite.Add(this.response);
                    }

                    //Take All Boat Info for Favorites
                    this.listboat   = Boats.SelectAllBoat();
                    this.listregion = Region.SelectAllRegion();
                    foreach (var item in responseAllFavorite)
                    {
                        this.boat          = this.listboat.Where(s => s.BOAT_ID == item.BOAT_ID).FirstOrDefault();
                        this.responseBoats = new ResponseBoats
                        {
                            BOAT_ID     = this.boat.BOAT_ID,
                            BOAT_INFO   = this.boat.BOAT_INFO,
                            BOAT_NAME   = this.boat.BOAT_NAME,
                            CAPTAIN_ID  = this.boat.CAPTAIN_ID,
                            FLAG        = this.boat.FLAG,
                            QUANTITY    = this.boat.QUANTITY,
                            REGION_ID   = this.boat.REGION_ID,
                            ROTA_INFO   = this.boat.ROTA_INFO,
                            REGION_NAME = Enum.GetName(typeof(Enums.Region), this.boat.REGION_ID),
                            header      = new ResponseHeader
                            {
                                IsSuccess       = true,
                                ResponseCode    = CommonDefinitions.SUCCESS,
                                ResponseMessage = CommonDefinitions.SUCCESS_MESSAGE
                            }
                        };

                        reponseAllBoats.Add(this.responseBoats);
                    }

                    #endregion
                    break;

                case (int)OperationType.OperationTypes.DELETE:
                    #region DELETE
                    if (!this.request.IsDeleteByCustomerNumber)
                    {
                        this.favorite = new Favorites
                        {
                            INSERT_USER     = this.request.INSERT_USER,
                            UPDATE_USER     = this.request.UPDATE_USER,
                            CUSTOMER_NUMBER = this.request.CUSTOMER_NUMBER,
                            BOAT_ID         = this.request.BOAT_ID
                        };

                        if (Favorites.Delete(this.favorite))
                        {
                            this.response = new ResponseFavorites
                            {
                                CUSTOMER_NUMBER = this.favorite.CUSTOMER_NUMBER,
                                BOAT_ID         = this.favorite.BOAT_ID,
                                header          = new ResponseHeader
                                {
                                    IsSuccess       = true,
                                    ResponseCode    = CommonDefinitions.SUCCESS,
                                    ResponseMessage = CommonDefinitions.SUCCESS_MESSAGE
                                }
                            };
                        }
                    }
                    else
                    {
                        //Delete all Favorites Boats for customer
                        if (Favorites.DeleteAllforCustomer(this.favorite.CUSTOMER_NUMBER))
                        {
                            this.response = new ResponseFavorites
                            {
                                CUSTOMER_NUMBER = this.favorite.CUSTOMER_NUMBER,
                                BOAT_ID         = this.favorite.BOAT_ID,
                                header          = new ResponseHeader
                                {
                                    IsSuccess       = true,
                                    ResponseCode    = CommonDefinitions.SUCCESS,
                                    ResponseMessage = CommonDefinitions.SUCCESS_MESSAGE
                                }
                            };
                        }
                    }

                    #endregion
                    break;

                default:
                    break;
                }
            }
            catch (Exception ex)
            {
                string operationError = "HATA:[" + "CustomerNumber:" + this.request.CUSTOMER_NUMBER + ",ResponseCode:" + this.baseResponseMessage.header.ResponseCode + ", ResponseMessage:" + ex.Message + "]";
                log.InfoFormat(operationError, ex);
                throw new Exception(ex.Message, ex.InnerException);
            }
        }
Beispiel #7
0
        public static void AddTransaction(RequestPayment request, ref bool checkValue)
        {
            try
            {
                long          checkguid    = 0;
                ResponseBoats responseBoat = GetBoatInfo(request.BOAT_ID);
                ResponsePersonalInformation responseCustomer = GetCustomer(request.CUSTOMER_NUMBER);
                PaymentTransaction          transaction      = new PaymentTransaction
                {
                    BOAT_ID          = request.BOAT_ID,
                    CALLBACK_URL     = request.CALLBACK_URL,
                    CARD_HOLDER_NAME = request.CARD_HOLDER_NAME,
                    CARD_REF_NUMBER  = request.CARD_REF_NUMBER,
                    CONVERSATION_ID  = request.CONVERSATION_ID,
                    CURRENCY         = request.CURRENCY,
                    CUSTOMER_NUMBER  = request.CUSTOMER_NUMBER,
                    IP              = request.IP,
                    PAID_PRICE      = request.PAID_PRICE,
                    PRICE           = request.PRICE,
                    PAYMENT_CHANNEL = request.PAYMENT_CHANNEL,
                    PAYMENT_ID      = request.PAYMENT_ID,
                    TOUR_TYPE       = responseBoat.TOUR_TYPE,
                    PAYMENT_TYPE    = request.Header.OperationTypes.ToString(),
                    UPDATE_USER     = responseCustomer.UPDATE_USER,
                    INSERT_USER     = responseCustomer.INSERT_USER
                };
                checkguid = paymentTransactionService.Insert(transaction);
                if (checkguid == 0)
                {
                    checkValue = false;
                }
                else
                {
                    checkValue = true;
                }

                //Reservation date  && id will be update
                Reservation reservation = new Reservation
                {
                    UPDATE_USER          = responseCustomer.UPDATE_USER,
                    INSERT_USER          = responseCustomer.INSERT_USER,
                    CUSTOMER_NUMBER      = request.CUSTOMER_NUMBER,
                    BOAT_ID              = request.BOAT_ID,
                    PAYMENT_ID           = request.PAYMENT_ID,
                    PAYMENT_TYPE         = request.Header.OperationTypes.ToString(),
                    PRICE                = request.PRICE,
                    TOUR_TYPE            = request.TOUR_TYPE,
                    RESERVATION_DATE     = request.RESERVATION_DATE,
                    RESERVATION_END_DATE = request.RESERVATION_END_DATE,
                    RESERVATION_ID       = request.RESERVATION_ID,
                    CONFIRM              = 0
                };
                //Modify Reservation Informations
                checkValue = reservationService.Update(reservation);
            }
            catch (Exception ex)
            {
                log.Error("AddTransaction has an ERROR: [ERROR : " + ex.Message + "]");
                throw new Exception(ex.Message);
            }
        }