示例#1
0
        private Guid GetContactId(Dictionary <string, object> requestData)
        {
            if (requestData != null && requestData.ContainsKey("client") && requestData["client"] != null)
            {
                var client      = (requestData["client"] as JObject).ToObject <Dictionary <string, string> >();
                var mobilePhone = client.ContainsKey("mobilePhone") ? client["mobilePhone"] ?? String.Empty : String.Empty;
                var cardNumber  = client.ContainsKey("cardNumber") ? client["cardNumber"] ?? String.Empty : String.Empty;
                var id          = client.ContainsKey("id") ? client["id"] ?? Guid.Empty.ToString() : Guid.Empty.ToString();

                mobilePhone = mobilePhone.Replace("+", String.Empty);

                var provider  = new LoyaltyDBProvider();
                var contactId = provider.ExecuteScalar <Guid>(@"Select ""Id"" from public.""Contact""
					Where
						(""Phone"" = '{0}' and '{0}' <> '')
					or
						(""Id"" = '{1}' and '{1}' <> '00000000-0000-0000-0000-000000000000')
					or
						('{2}' <> '' and (Select COUNT(*) from public.""Card"" Where ""ContactId"" = ""Contact"".""Id"" and ""Number"" = '{2}') > 0)"                        ,
                                                              Guid.Empty, mobilePhone, id, cardNumber);
                return(contactId);
            }

            return(Guid.Empty);
        }
示例#2
0
        private Int64 GetPromocodeInPurchaseCount(Guid promocodeId)
        {
            var provider = new LoyaltyDBProvider();

            return(provider.ExecuteScalar <Int64>(@"Select COUNT(*) from public.""PromoCodeInPurchase"" Where ""PromoCodeId"" = '{0}'", 0L, promocodeId.ToString()));
        }