Exemplo n.º 1
0
        private MsCrmResult SendToService(UserGiftRequest request)
        {
            MsCrmResult returnValue = new MsCrmResult();

            try
            {
                string cityCode = string.Empty;

                MsCrmResultObject resultGetGiftInfo = GiftHelper.GetGiftInfo(request.GiftId.Id, _sda);
                MsCrmResultObject resultUserInfo    = PortalUserHelper.GetPortalUserDetail(request.PortalId.Id, request.UserId.Id, _sda);

                if (!resultGetGiftInfo.Success)
                {
                    returnValue.Result = resultGetGiftInfo.Result;

                    return(returnValue);
                }

                if (!resultUserInfo.Success)
                {
                    returnValue.Result = resultUserInfo.Result;

                    return(returnValue);
                }

                Gift       gift     = resultGetGiftInfo.GetReturnObject <Gift>();
                PortalUser userInfo = resultUserInfo.GetReturnObject <PortalUser>();

                StringBuilder sb          = new StringBuilder();
                bool          checkFailed = false;

                if (userInfo.ContactInfo.CityId == null)
                {
                    sb.AppendLine("İl bilgisi eksik");
                    checkFailed = true;
                }

                if (userInfo.ContactInfo.TownId == null)
                {
                    sb.AppendLine("İlçe bilgisi eksik");
                    checkFailed = true;
                }

                if (string.IsNullOrWhiteSpace(userInfo.ContactInfo.MobilePhone))
                {
                    sb.AppendLine("Cep telefonu bilgisi eksik.");
                    checkFailed = true;
                }

                TelephoneNumber telNo = ValidationHelper.CheckTelephoneNumber(userInfo.ContactInfo.MobilePhone);

                if (!telNo.isFormatOK)
                {
                    sb.AppendLine("Telefon numarası formatı hatalı.");
                    checkFailed = true;
                }


                if (checkFailed)
                {
                    returnValue.Result = sb.ToString();

                    return(returnValue);
                }

                cityCode = ContactHelper.GetCityCode(userInfo.ContactInfo.CityId.Id, _sda);

                interlinkService.OperactiveOrder oo = new interlinkService.OperactiveOrder();

                string result = oo.OrderAdd("Interlink-Service2q2k", Globals.InterlinkPartnerId, DateTime.Now.ToLongDateString()
                                            , gift.GiftCode, 1, userInfo.ContactInfo.AddressDetail, userInfo.ContactInfo.CityId.Name, userInfo.ContactInfo.TownId.Name, cityCode
                                            , userInfo.ContactInfo.FirstName, userInfo.ContactInfo.LastName, string.Empty, string.Empty
                                            , telNo.phoneCode, telNo.phoneNo, userInfo.ContactInfo.Title, request.Id.ToString(), "Portal PUAN KULLANIMI"
                                            , Globals.InterlinkCatalogId, userInfo.PortalUserId.ToString());

                //result = "0001";

                FileLogHelper.LogFunction(this.GetType().Name, "Result:" + result + ",Id:" + request.Id.ToString(), @Globals.FileLogPath);

                string errorText = string.Empty;

                bool hasError = GiftHelper.InterlinkOrderErrorCodes.TryGetValue(result, out errorText);

                if (string.IsNullOrWhiteSpace(errorText))
                {
                    returnValue.Result  = result;
                    returnValue.Success = true;
                }
                else
                {
                    returnValue.Result = errorText;
                }
            }
            catch (Exception ex)
            {
                returnValue.Result = ex.StackTrace;
            }

            return(returnValue);
        }
Exemplo n.º 2
0
        private MsCrmResult SendToService(UserGiftRequest request)
        {
            MsCrmResult returnValue = new MsCrmResult();

            try
            {
                string cityCode = string.Empty;

                MsCrmResultObject resultGetGiftInfo = GiftHelper.GetGiftInfo(request.GiftId.Id, _sda);
                MsCrmResultObject resultUserInfo = PortalUserHelper.GetPortalUserDetail(request.PortalId.Id, request.UserId.Id, _sda);

                if (!resultGetGiftInfo.Success)
                {
                    returnValue.Result = resultGetGiftInfo.Result;

                    return returnValue;
                }

                if (!resultUserInfo.Success)
                {
                    returnValue.Result = resultUserInfo.Result;

                    return returnValue;
                }

                Gift gift = resultGetGiftInfo.GetReturnObject<Gift>();
                PortalUser userInfo = resultUserInfo.GetReturnObject<PortalUser>();

                StringBuilder sb = new StringBuilder();
                bool checkFailed = false;

                if (userInfo.ContactInfo.CityId == null)
                {
                    sb.AppendLine("İl bilgisi eksik");
                    checkFailed = true;
                }

                if (userInfo.ContactInfo.TownId == null)
                {
                    sb.AppendLine("İlçe bilgisi eksik");
                    checkFailed = true;
                }

                if (string.IsNullOrWhiteSpace(userInfo.ContactInfo.MobilePhone))
                {
                    sb.AppendLine("Cep telefonu bilgisi eksik.");
                    checkFailed = true;
                }

                TelephoneNumber telNo = ValidationHelper.CheckTelephoneNumber(userInfo.ContactInfo.MobilePhone);

                if (!telNo.isFormatOK)
                {
                    sb.AppendLine("Telefon numarası formatı hatalı.");
                    checkFailed = true;
                }

                if (checkFailed)
                {
                    returnValue.Result = sb.ToString();

                    return returnValue;
                }

                cityCode = ContactHelper.GetCityCode(userInfo.ContactInfo.CityId.Id, _sda);

                interlinkService.OperactiveOrder oo = new interlinkService.OperactiveOrder();

                string result = oo.OrderAdd("Interlink-Service2q2k", Globals.InterlinkPartnerId, DateTime.Now.ToLongDateString()
                    , gift.GiftCode, 1, userInfo.ContactInfo.AddressDetail, userInfo.ContactInfo.CityId.Name, userInfo.ContactInfo.TownId.Name, cityCode
                    , userInfo.ContactInfo.FirstName, userInfo.ContactInfo.LastName, string.Empty, string.Empty
                    , telNo.phoneCode, telNo.phoneNo, userInfo.ContactInfo.Title, request.Id.ToString(), "Portal PUAN KULLANIMI"
                    , Globals.InterlinkCatalogId, userInfo.PortalUserId.ToString());

                //result = "0001";

                FileLogHelper.LogFunction(this.GetType().Name, "Result:" + result + ",Id:" + request.Id.ToString(), @Globals.FileLogPath);

                string errorText = string.Empty;

                bool hasError = GiftHelper.InterlinkOrderErrorCodes.TryGetValue(result, out errorText);

                if (string.IsNullOrWhiteSpace(errorText))
                {
                    returnValue.Result = result;
                    returnValue.Success = true;
                }
                else
                {
                    returnValue.Result = errorText;
                }
            }
            catch (Exception ex)
            {
                returnValue.Result = ex.StackTrace;
            }

            return returnValue;
        }