/// <summary>
        /// The the location id in data model representation.
        /// </summary>
        /// <param name="emailSubscription"> The email subscription. </param>
        /// <returns> The <see cref="string"/>. </returns>
        private string GetDataModelLocationId(LoMo.UserServices.DataContract.Location emailSubscription)
        {
            Users.Dal.DataModel.LocationType type = (Users.Dal.DataModel.LocationType)Enum.Parse(typeof(Users.Dal.DataModel.LocationType), emailSubscription.LocationType.ToString());
            Location location = new Location(emailSubscription.CountryCode, emailSubscription.AdminDistrict, emailSubscription.LocationName, type);

            return(location.ToString());
        }
        public HttpResponseMessage UnSubscribe(LoMo.UserServices.DataContract.Location emailSubscription)
        {
            Guid userId = Security.GetUserId();

            Log.Verbose("Start unsubscribe request. User id: {0}", userId);
            string invalidReason;

            if (!this.ValidateApiUnsubscribe(emailSubscription, out invalidReason))
            {
                Log.Info("Unsubscribe request with invalid subscription. User Id: {0}. Invalid Reason: {1}", userId, invalidReason);
                var errorResponse = Request.CreateErrorResponse(HttpStatusCode.BadRequest, invalidReason);
                throw new HttpResponseException(errorResponse);
            }

            try
            {
                string locationId = this.GetDataModelLocationId(emailSubscription);
                Log.Verbose("unsubscribe request Completed Succefully. User Id {0}", userId);
                this.usersDal.DeleteEmailSubscriptions(userId, SubscriptionType.WeeklyDeals, locationId);
                return(new HttpResponseMessage(HttpStatusCode.Accepted));
            }
            catch (Exception e)
            {
                Log.Error(e, "Couldn't unsubscribe. User Id: {0}", userId);
                throw new HttpResponseException(HttpStatusCode.InternalServerError);
            }
        }
        /// <summary>
        /// The validate subscription. </summary> <param name="emailSubscription">
        /// The email subscription. </param>
        /// <param name="reason"> in case of validation failure will include the reason</param>
        ///  <returns> is valid subscription argument value
        /// </returns>
        private bool ValidateApiUnsubscribe(LoMo.UserServices.DataContract.Location emailSubscription, out string reason)
        {
            if (emailSubscription == null)
            {
                reason = "Subscription information is emtpy";
                return(false);
            }

            if (emailSubscription.LocationType == LocationType.None)
            {
                reason = string.Format("Location type not exist. The actual value is: {0}", emailSubscription.LocationType);
                return(false);
            }

            reason = string.Empty;
            return(true);
        }