/// <summary>
        /// Reactivation consists in switch the status of the profile
        /// to the 'active' state but only if the profile fullfill the constraints
        /// for 'active profiles', so the profile can get stucked
        /// in the non-active state as a result, pending on requesting
        /// a reactivation once its contraints are fullfilled.
        /// </summary>
        /// <param name="userID"></param>
        /// <param name="jobTitleID"></param>
        /// <returns></returns>
        public static bool ReactivateUserJobTitle(int userID, int jobTitleID)
        {
            using (var db = Database.Open("sqlloco")) {
                // Check the current StatusID
                var statusID = LcData.UserInfo.GetUserPositionStatus(userID, jobTitleID);

                // If status is -1, the records does not exists
                if (statusID == -1)
                {
                    return(false);
                }

                // If status is of type 3 'private profile, manual activation'..
                if (statusID == 3)
                {
                    // ..modify the profile StatusID from 3 to 2 'private profile, automatic activation'
                    // (because the TestProfileActivation only works for StatusID:2 to avoid unexpected changes)
                    db.Execute(@"
                        UPDATE  UserProfilePositions
                        SET     StatusID = 2,
                                UpdatedDate = getdate()
                        WHERE UserID = @0 AND PositionID = @1
                         AND LanguageID = @2
                         AND CountryID = @3
                    ", userID, jobTitleID,
                               LcData.GetCurrentLanguageID(), LcData.GetCurrentCountryID());
                }

                // It executes the profile activation that checks that all required alerts must be off to activate:
                db.Execute("EXEC TestProfileActivation @0, @1", userID, jobTitleID);

                // Check the updated StatusID
                var newStatusID = LcData.UserInfo.GetUserPositionStatus(userID, jobTitleID);
                // If the status is 1 'public profile', success!
                if (newStatusID == 1)
                {
                    return(true);
                }
                else
                {
                    // It is Not activated still, required alerts are pending, back to the original
                    // StatusID if was not 2 originally (it was updated in the middle of the process to run
                    // the TestProfileActivation procedure)
                    if (statusID >= 2)
                    {
                        db.Execute(@"
                            UPDATE UserProfilePositions
                            SET     StatusID = @2,
                                    UpdatedDate = getdate()
                            WHERE UserID = @0 AND PositionID = @1
                             AND LanguageID = @3
                             AND CountryID = @4
                        ", userID, jobTitleID, statusID,
                                   LcData.GetCurrentLanguageID(), LcData.GetCurrentCountryID());
                    }

                    return(false);
                }
            }
        }
Esempio n. 2
0
 public static UserJobTitle GetItem(int userID, int jobTitleID)
 {
     using (var db = Database.Open("sqlloco"))
     {
         return(FromDB(db.QuerySingle(sqlGet, userID, LcData.GetCurrentLanguageID(), LcData.GetCurrentCountryID(), jobTitleID)));
     }
 }
 public static dynamic GetUserJobTitles(int userID, int jobTitleID = -1)
 {
     using (var db = Database.Open("sqlloco"))
     {
         return(db.Query(@"
             SELECT
                 u.UserID As userID,
                 u.PositionID As jobTitleID,
                 u.PositionIntro As intro,
                 u.StatusID As statusID,
                 u.CancellationPolicyID As cancellationPolicyID,
                 u.InstantBooking As instantBooking,
                 u.CreateDate As createdDate,
                 u.UpdatedDate As updatedDate,
                 u.bookMeButtonReady As bookMeButtonReady,
                 u.collectPaymentAtBookMeButton As collectPaymentAtBookMeButton
             FROM
                 userprofilepositions as u
                  INNER JOIN
                 positions on u.positionID = positions.positionID AND positions.languageID = @1 and positions.countryID = @2
             WHERE
                 u.UserID = @0
                  AND u.LanguageID = @1
                  AND u.CountryID = @2
                  AND u.Active = 1
                  AND u.StatusID > 0
                  AND (@3 = -1 OR @3 = u.PositionID)
                  -- Double check for approved positions
                  AND positions.Active = 1
                  AND (positions.Approved = 1 Or positions.Approved is null) -- Avoid not approved, allowing pending (null) and approved (1)
         ", userID, LcData.GetCurrentLanguageID(), LcData.GetCurrentCountryID(), jobTitleID));
     }
 }
Esempio n. 4
0
        public static bool Update(UserJobTitle userJobTitle)
        {
            userJobTitle.ValidateAndFixBookingPolicies();
            var sqlUpdate = @"
                UPDATE  UserProfilePositions
                SET     PositionIntro = @4,
                        CancellationPolicyID = @5,
                        InstantBooking = @6,
                        collectPaymentAtBookMeButton = @7,
                        UpdatedDate = getdate()
                WHERE   UserID = @0 AND PositionID = @1
                    AND LanguageID = @2
                    AND CountryID = @3
            ";

            using (var db = new LcDatabase())
            {
                var affected = db.Execute(sqlUpdate,
                                          userJobTitle.userID,
                                          userJobTitle.jobTitleID,
                                          LcData.GetCurrentLanguageID(),
                                          LcData.GetCurrentCountryID(),
                                          userJobTitle.intro,
                                          userJobTitle.cancellationPolicyID,
                                          userJobTitle.instantBooking,
                                          userJobTitle.collectPaymentAtBookMeButton
                                          );

                // Task done? Almost a record must be affected to be a success
                return(affected > 0);
            }
        }
Esempio n. 5
0
        /* Get a data object with the Position row of the user 'userId' with PositionId 'posId' from the database
         */
        public static dynamic GetUserPos(int userId, int posId, int langID = 0, int countryID = 0)
        {
            if (langID == 0)
            {
                langID = LcData.GetCurrentLanguageID();
            }
            if (countryID == 0)
            {
                countryID = LcData.GetCurrentCountryID();
            }

            // Implemented a basic, per-page, cache, faster and simplified for each page
            var u = HelperPage.PageData["userpos:" + userId.ToString() + ":" + posId.ToString()];

            if (u == null)
            {
                using (var db = Database.Open("sqlloco")){
                    var sqlpositions = @"
                        SELECT  a.UserID, a.PositionID, a.Active, a.StatusID, InstantBooking,
                                PositionSingular, PositionPlural, a.UpdatedDate, a.PositionIntro
                        FROM    dbo.userprofilepositions a join positions c on a.PositionID = c.PositionID 
                        WHERE   a.UserID = @0 and a.PositionID = @1 and c.LanguageID = @2 and c.CountryID = @3
                                AND c.Active = 1 AND a.Active = 1 AND a.StatusID > 0";
                    u = db.QuerySingle(sqlpositions, userId, posId, langID, countryID);
                }
                HelperPage.PageData["userpos:" + userId.ToString() + ":" + posId.ToString()] = u;
            }
            return(u);
        }
Esempio n. 6
0
        public static Address GetHomeAddress(int userID)
        {
            using (var db = Database.Open("sqlloco"))
            {
                // Parameter jobTitleID needs to be specified as 0 to avoid to join
                // the service-address table
                // Null value as 3th parameter since that placeholder is reserved for addressID
                // NOTE: Home address must exists ever, if there is no one on databsae but
                // user exists, just default/null values per field are returned but a record
                // is returned.
                var add = GetSingleFrom(db.Query(
                                            sqlSelectOne + sqlFields + sqlAndCreatedByItself + sqlAndUserID + sqlAndTypeID,
                                            LcData.GetCurrentLanguageID(), userID, null, null, AddressType.Home
                                            ));

                if (add == null)
                {
                    add = new Address
                    {
                        // L10N
                        addressName = "Home",
                        userID      = userID,
                        kind        = AddressKind.Home
                    };
                }
                return(add);
            }
        }
Esempio n. 7
0
 public static IEnumerable <UserJobTitle> GetByUser(int userID)
 {
     using (var db = Database.Open("sqlloco"))
     {
         return(db.Query(sqlGet, userID, LcData.GetCurrentLanguageID(), LcData.GetCurrentCountryID(), -1).Select(FromDB));
     }
 }
Esempio n. 8
0
 /// <summary>
 /// Checks whether the user has the job title assigned already (publicly active or not).
 /// Does not include blocked records (Active=0).
 /// </summary>
 /// <param name="userID"></param>
 /// <param name="jobTitleID"></param>
 /// <param name="languageID"></param>
 /// <param name="countryID"></param>
 /// <returns></returns>
 public static Boolean HasItem(int userID, int jobTitleID, int?languageID = null, int?countryID = null)
 {
     languageID = languageID ?? LcData.GetCurrentLanguageID();
     countryID  = countryID ?? LcData.GetCurrentCountryID();
     using (var db = new LcDatabase())
     {
         return(db.QuerySingle(sqlGetActiveOrInactiveItem, userID, languageID, countryID, jobTitleID) != null);
     }
 }
Esempio n. 9
0
 public static Address GetServiceAddress(int userID, int jobTitleID, int addressID)
 {
     using (var db = Database.Open("sqlloco"))
     {
         return(GetSingleFrom(db.Query(
                                  sqlSelectOne + sqlFields + sqlAndCreatedByItself + sqlAndUserID + sqlAndJobTitleID + sqlAndAddressID + sqlcondOnlyActiveServiceAddress,
                                  LcData.GetCurrentLanguageID(), userID, jobTitleID, addressID
                                  )));
     }
 }
Esempio n. 10
0
        private static IEnumerable <UserJobTitle> GetListByUser(string sql, int userID)
        {
            using (var db = new LcDatabase())
            {
                var userJobTitles = db.Query(sql, userID, LcData.GetCurrentLanguageID(), LcData.GetCurrentCountryID())
                                    .Select(FromDB);

                return(BindAlerts(userJobTitles, Alert.IndexByPosition(Alert.GetActive(userID))));
            }
        }
Esempio n. 11
0
 public static List <Address> GetServiceAddresses(int userID, int jobTitleID)
 {
     using (var db = Database.Open("sqlloco"))
     {
         var sql = sqlSelect + sqlFields + sqlAndCreatedByItself + sqlAndUserID + sqlAndJobTitleID + (jobTitleID > 0 ? sqlcondOnlyActiveServiceAddress : sqlcondOnlyNamedAddresses);
         return(db.Query(sql,
                         LcData.GetCurrentLanguageID(), userID, jobTitleID)
                .Select(FromDB)
                .ToList());
     }
 }
Esempio n. 12
0
 public static dynamic GetActiveUserAlerts(int userID, int positionID = -1)
 {
     using (var db = Database.Open("sqlloco")) {
         return(db.Query(@"
         SELECT  A.AlertID,
                 A.AlertTypeID,
                 A.AlertName,
                 A.AlertHeadlineDisplay,
                 A.AlertTextDisplay,
                 A.AlertDescription,
                 A.AlertPageURL,
                 A.DisplayRank,
                 A.PositionSpecific,
                 A.Required,
                 UA.PositionID,
                 AT.AlertTypeName,
                 AT.AlertTypeDescription,
                 P.PositionSingular
         FROM    Alert As A
                  INNER JOIN
                 UserAlert As UA
                   ON A.AlertID = UA.AlertID
                  INNER JOIN
                 AlertType As AT
                   ON AT.AlertTypeID = A.AlertTypeID
                  LEFT JOIN (
                 Positions As P
                  INNER JOIN
                 UserProfilePositions As UP
                   ON UP.PositionID = P.PositionID
                      AND UP.Active = 1
                      AND UP.StatusID > 0
                      AND UP.LanguageID = P.LanguageID
                      AND UP.CountryID = P.CountryID
                 )
                   ON P.PositionID = UA.PositionID
                      AND P.LanguageID = A.LanguageID
                      AND P.CountryID = A.CountryID
                      AND UP.UserID = UA.UserID
         WHERE   UA.Active = 1 AND A.Active = 1 AND UA.UserID = @0
                  AND A.LanguageID = @1 AND A.CountryID = @2
                  AND (UA.PositionID = 0 OR P.PositionID is not null)
                 -- Filtered optionally by position (-1 to not filter by position)
                  AND (UA.PositionID = 0 OR @3 = -1 OR UA.PositionID = @3)
                 -- Added dismissed feature #243: not show if is dismissed
                 -- except for required ones, that cannot be dismissed
                 AND (A.Required = 1 OR UA.Dismissed = 0)
         ORDER BY AT.DisplayRank, AT.AlertTypeName, A.DisplayRank, A.AlertName
         ", userID,
                         LcData.GetCurrentLanguageID(),
                         LcData.GetCurrentCountryID(),
                         positionID));
     }
 }
Esempio n. 13
0
 public static Address GetBillingAddress(int userID, int addressID)
 {
     using (var db = Database.Open("sqlloco"))
     {
         // Parameter jobTitleID needs to be specified as 0 to avoid to join
         // the service-address table
         return(GetSingleFrom(db.Query(
                                  sqlSelectOne + sqlFields + sqlAndCreatedByItself + sqlAndUserID + sqlAndJobTitleID + sqlAndAddressID + sqlAndTypeID,
                                  LcData.GetCurrentLanguageID(), userID, NotAJobTitleID, addressID, AddressType.Billing
                                  )));
     }
 }
Esempio n. 14
0
 private static dynamic QueryPackageServiceAttributesByMulti(Database db, int providerUserID, int positionID = -1, int packageID = -1, int pricingTypeID = -1, bool?isAddon = null)
 {
     return(db.Query(SQLGetPackageServiceAttributesByMulti,
                     providerUserID,
                     positionID,
                     LcData.GetCurrentLanguageID(),
                     LcData.GetCurrentCountryID(),
                     packageID,
                     pricingTypeID,
                     (isAddon.HasValue ? (isAddon.Value ? 1 : 0) : -1)
                     ));
 }
Esempio n. 15
0
 public static IEnumerable <Alert> GetActive(int userID, int positionID = -1)
 {
     using (var db = new LcDatabase())
     {
         return(db.Query(
                    sqlSelect, userID,
                    LcData.GetCurrentLanguageID(),
                    LcData.GetCurrentCountryID(),
                    positionID)
                .Select(FromDB));
     }
 }
Esempio n. 16
0
 public static List <Address> GetBillingAddresses(int userID)
 {
     using (var db = Database.Open("sqlloco"))
     {
         // Parameter jobTitleID needs to be specified as 0 to avoid to join
         // the service-address table
         // Null value as 3th parameter since that placeholder is reserved for addressID
         return(db.Query(sqlSelect + sqlFields + sqlAndCreatedByItself + sqlAndUserID + sqlAndJobTitleID + sqlAndTypeID,
                         LcData.GetCurrentLanguageID(), userID, NotAJobTitleID, null, AddressType.Billing)
                .Select(FromDB)
                .ToList());
     }
 }
 private static void Load(PricingVariables data, int userID, int packageID, int pricingEstimateID = 0, int pricingEstimateRevision = 0)
 {
     using (var db = Database.Open("sqlloco"))
     {
         var vars = db.Query(sqlGetVariablesActualValues, userID, packageID, pricingEstimateID, pricingEstimateRevision,
                             LcData.GetCurrentLanguageID(), LcData.GetCurrentCountryID());
         foreach (var r in vars)
         {
             var varValue = PricingVariableValue.CreateFromDbRecord(r);
             data[r.InternalName] = varValue;
             // Update index
             data.idIndex[varValue.PricingVariableID] = varValue;
         }
     }
 }
Esempio n. 18
0
 /// <summary>
 /// Get the list of active service addresses created by a given user on behalf of another user, optionally for a specific
 /// jobTitleID
 /// </summary>
 /// <param name="createdByUserID"></param>
 /// <param name="onBehalfOfUserID"></param>
 /// <param name="jobTitleID"></param>
 /// <returns></returns>
 public static IEnumerable <Address> GetAddressesCreatedByOnBehalfOf(int createdByUserID, int onBehalfOfUserID, int jobTitleID = 0)
 {
     using (var db = Database.Open("sqlloco"))
     {
         var sql = sqlSelect + sqlFields + sqlAndUserID + sqlcondOnlyActiveServiceAddress;
         if (jobTitleID > 0)
         {
             sql += sqlAndJobTitleID;
         }
         sql += sqlAndCreatedBy;
         return(db.Query(sql,
                         LcData.GetCurrentLanguageID(), onBehalfOfUserID, jobTitleID, createdByUserID)
                .Select(FromDB));
     }
 }
Esempio n. 19
0
 /// <summary>
 /// Returns the address for the ID only if is owned by one of the given userIds.
 /// This is usefull at bookings, when the address for the service can be a service professional service address
 /// or a personal client address, there is no knowledgment of who is the owner in the booking info so
 /// can be any of both.
 /// </summary>
 /// <param name="addressID"></param>
 /// <param name="anyFromUserIds"></param>
 /// <returns></returns>
 public static Address GetAddress(int addressID, IEnumerable <int> anyFromUserIds)
 {
     using (var db = Database.Open("sqlloco"))
     {
         var idList             = String.Join(",", anyFromUserIds);
         var sqlAndUserIdInList = " AND L.UserID IN (" + idList + ") ";
         return(GetSingleFrom(db.Query(
                                  sqlSelectOne + sqlFields + sqlAndUserIdInList + sqlAndAddressID,
                                  LcData.GetCurrentLanguageID(),
                                  null,           // There is no @1 on this SQL
                                  NotAJobTitleID, // @2 has special meaning on the SQL, avoid some bad results
                                  addressID
                                  )));
     }
 }
Esempio n. 20
0
    public static AccountEmailInfo GetAccountInfo(int userID, int?jobTitleID = null)
    {
        var a = new AccountEmailInfo
        {
            userID = userID
        };

        if (jobTitleID.HasValue)
        {
            var languageID = LcData.GetCurrentLanguageID();
            var countryID  = LcData.GetCurrentCountryID();
            a.userJobTitle = LcRest.PublicUserJobTitle.Get(userID, languageID, countryID, jobTitleID.Value, true);
        }

        return(a);
    }
Esempio n. 21
0
        public static void Create(UserJobTitle userJobTitle)
        {
            userJobTitle.ValidateAndFixBookingPolicies();
            using (var db = new LcDatabase())
            {
                var results = db.QuerySingle("EXEC dbo.InsertUserProfilePositions @0, @1, @2, @3, @4, @5, @6, @7, @8",
                                             userJobTitle.userID,
                                             userJobTitle.jobTitleID,
                                             LcData.GetCurrentLanguageID(),
                                             LcData.GetCurrentCountryID(),
                                             userJobTitle.cancellationPolicyID,
                                             userJobTitle.intro,
                                             userJobTitle.instantBooking,
                                             userJobTitle.collectPaymentAtBookMeButton,
                                             userJobTitle.title);

                if (results.Result != "Success")
                {
                    // TODO: Add better error checks (codes) at new back-end when porting this rather than local text errors
                    var message = (string)results.Result;
                    if (message.Contains("Cannot insert duplicate key"))
                    {
                        if (userJobTitle.jobTitleID == UserGeneratedJobTitleID)
                        {
                            throw new ConstraintException("We're sorry, but we currently only support one custom job title (stay tunned, this will change soon!).");
                        }
                        else
                        {
                            throw new ConstraintException("You already have a listing with that job title.");
                        }
                    }
                    else
                    {
                        throw new Exception("We're sorry, there was an error creating your listing: " + message);
                    }
                }
                else
                {
                    // Additional data for the new listing:
                    // Needs the default solutions
                    if ((int)results.userListingID > 0)
                    {
                        UserSolution.SetDefaultSolutionsForListing((int)results.userListingID);
                    }
                }
            }
        }
Esempio n. 22
0
 public static int GetUserPositionStatus(int userID, int positionID)
 {
     using (var db = Database.Open("sqlloco"))
     {
         var statusID = db.QueryValue("SELECT StatusID FROM UserProfilePositions WHERE UserID = @0 AND PositionID = @1 AND LanguageID = @2 AND LanguageID = @3",
                                      userID, positionID, LcData.GetCurrentLanguageID(), LcData.GetCurrentCountryID());
         if (statusID is int)
         {
             return(statusID);
         }
         else
         {
             // There is no position for the user, there is no user, or not for the languagen and country
             return(-1);
         }
     }
 }
Esempio n. 23
0
    public static BookingEmailInfo GetBookingInfo(int bookingID)
    {
        var bID = bookingID;
        // We need the booking including some internal sensitive data (like 'payment last four digits')
        // since here we have not enough context to know what userID is the target, and must not be a problem
        // since this data is never provided as is, but only used by the templates that must be carefull with what
        // data to show to every case.
        var b = LcRest.Booking.Get(bID, true, true);

        if (b == null)
        {
            throw new Exception("BookingID not found #" + bID + ", at Email template");
        }

        /* Generics not used in new email template organization, but keep this commented
         * for any future chance:
         * var url = Request.Url.OriginalString.ToUpper();
         * var sentTo = LcData.UserInfo.UserType.None;
         * if (url.IndexOf("/TOCLIENT/") > -1) {
         *  sentTo = LcData.UserInfo.UserType.Client;
         * }
         * else if (url.IndexOf("/TOSERVICEPROFESSIONAL/") > -1) {
         *  sentTo = LcData.UserInfo.UserType.ServiceProfessional;
         * }
         * int toUserID = 0;
         * if (sentTo == LcData.UserInfo.UserType.ServiceProfessional) {
         *  toUserID = b.serviceProfessionalUserID;
         * }
         * else if (sentTo == LcData.UserInfo.UserType.Client) {
         *  toUserID = b.clientUserID;
         * }
         */

        // Cancellation policy
        var policy = LcRest.CancellationPolicy.Get(b.cancellationPolicyID, LcData.GetCurrentLanguageID(), LcData.GetCurrentCountryID());

        return(new BookingEmailInfo
        {
            booking = b,
            //servicePricing = GetForPricingSummary(b.pricingSummary),
            userJobTitle = b.userJobTitle,
            cancellationPolicy = policy
                                 //,SentTo = sentTo
                                 //,SentToUserID = toUserID
        });
    }
Esempio n. 24
0
        public static bool SoftDeleteUserJobTitle(int userID, int jobTitleID)
        {
            using (var db = Database.Open("sqlloco")) {
                // Set StatusID to 0 'deleted by user'
                int affected = db.Execute(@"
                    UPDATE UserProfilePositions
                    SET     StatusID = 0,
                            UpdatedDate = getdate()
                    WHERE UserID = @0 AND PositionID = @1
                     AND LanguageID = @2
                     AND CountryID = @3
                ", userID, jobTitleID, LcData.GetCurrentLanguageID(), LcData.GetCurrentCountryID());

                // Task done? Almost a record must be affected to be a success
                return(affected > 0);
            }
        }
Esempio n. 25
0
        private static dynamic QueryPackagesByMulti(Database db, int providerUserID, int positionID = -1, int packageID = -1, int pricingTypeID = -1, bool?isAddon = null, Visibility clientVisibility = null)
        {
            // By default, return pricings that are bookable by the public
            clientVisibility = clientVisibility ?? Visibility.BookableByPublic();

            const string SQLGetPackagesByMulti = SQLSelectFromPackage + @"
                         INNER JOIN
                        PricingType As PT
                          ON P.PricingTypeID = PT.PricingTypeID
                            AND P.LanguageID = PT.LanguageID
                            AND P.CountryID = PT.CountryID
                         INNER JOIN
                        PositionPricingType AS PPT
                          ON PPT.PositionID = P.PositionID
                            AND PPT.PricingTypeID = PT.PricingTypeID
                            AND PPT.LanguageID = PT.LanguageID
                            AND PPT.CountryID = PT.CountryID
                            AND PPT.Active = 1
                WHERE   p.ProviderUserID = @0
                         AND (@1 = -1 OR P.PositionID = @1)
                         AND 
                        p.LanguageID = @2 AND p.CountryID = @3
                         AND 
                        p.Active = 1
                         AND (@4 = -1 OR p.ProviderPackageID = @4)
                         AND (@5 = -1 OR p.PricingTypeID = @5)
                         AND (@6 = -1 OR P.IsAddOn = @6)
                         AND P.VisibleToClientID IN ({0})
                ORDER BY PT.DisplayRank ASC
            ";

            // Database.Query does not natively expand SQL IN clause list, so do it manually :(
            string query = String.Format(SQLGetPackagesByMulti, String.Join(",", clientVisibility.VisibleToClientIDs()));

            return(db.Query(query,
                            providerUserID,
                            positionID,
                            LcData.GetCurrentLanguageID(),
                            LcData.GetCurrentCountryID(),
                            packageID,
                            pricingTypeID,
                            (isAddon.HasValue ? (isAddon.Value ? 1 : 0) : -1)
                            ));
        }
Esempio n. 26
0
 public static dynamic GetPositionRatings(int positionID)
 {
     using (var db = Database.Open("sqlloco"))
     {
         return(db.QuerySingle(@"
             SELECT  TOP 1
                     Rating1, Rating2, Rating3
                     ,Rating1FormDescription, Rating2FormDescription, Rating3FormDescription
                     ,Rating1ProfileDescription, Rating2ProfileDescription, Rating3ProfileDescription
             FROM    PositionRatings
             WHERE   (PositionID = @0 OR PositionID = -1)
                     AND LanguageID = @1
                     AND CountryID = @2
             -- First, the specific ID, then the default PositionID=0. 
             -- If there is no specific, with TOP 1 we get the default
             ORDER BY PositionID DESC
         ", positionID, LcData.GetCurrentLanguageID(), LcData.GetCurrentCountryID()));
     }
 }
Esempio n. 27
0
        /// <summary>
        /// Deactivation consists in switch the status of the profile
        /// to 'manually disabled / private'.
        /// </summary>
        /// <param name="userID"></param>
        /// <param name="jobTitleID"></param>
        /// <returns></returns>
        public static bool DeactivateUserJobTitle(int userID, int jobTitleID)
        {
            using (var db = Database.Open("sqlloco")) {
                // It just update StatusID to 3 'private profile, manual activation'
                var affected = db.Execute(@"
                    UPDATE UserProfilePositions
                    SET     StatusID = 3,
                            UpdatedDate = getdate()
                    WHERE UserID = @0 AND PositionID = @1
                     AND LanguageID = @2
                     AND CountryID = @3
                ",
                                          userID, jobTitleID,
                                          LcData.GetCurrentLanguageID(), LcData.GetCurrentCountryID());

                // Task done? Almost a record must be affected to be a success
                return(affected > 0);
            }
        }
 /// <summary>
 /// Load the set of pricingVariables with the saved values for the given provider package
 /// updated with current set of variables assigned to the position and pricingType,
 /// suitable to fill the 'edit package' form.
 /// </summary>
 /// <param name="data"></param>
 /// <param name="userID"></param>
 /// <param name="packageID"></param>
 /// <param name="positionID"></param>
 /// <param name="pricingTypeID"></param>
 private static void LoadUpdated(PricingVariables data, int userID, int packageID, int positionID, int pricingTypeID)
 {
     using (var db = Database.Open("sqlloco"))
     {
         var vars = db.Query(sqlGetVariablesForEdit,
                             userID,
                             packageID,
                             positionID,
                             pricingTypeID,
                             LcData.GetCurrentLanguageID(),
                             LcData.GetCurrentCountryID());
         foreach (var r in vars)
         {
             var varValue = PricingVariableValue.CreateFromDbRecord(r);
             data[r.InternalName] = varValue;
             // Update index
             data.idIndex[varValue.PricingVariableID] = varValue;
         }
     }
 }
Esempio n. 29
0
        public static void Create(UserJobTitle userJobTitle)
        {
            using (var db = new LcDatabase())
            {
                var results = db.QuerySingle("EXEC dbo.InsertUserProfilePositions @0, @1, @2, @3, @4, @5, @6, @7",
                                             userJobTitle.userID,
                                             userJobTitle.jobTitleID,
                                             LcData.GetCurrentLanguageID(),
                                             LcData.GetCurrentCountryID(),
                                             userJobTitle.cancellationPolicyID,
                                             userJobTitle.intro,
                                             userJobTitle.instantBooking,
                                             userJobTitle.collectPaymentAtBookMeButton);

                if (results.Result != "Success")
                {
                    throw new Exception("We're sorry, there was an error creating your job title: " + results.Result);
                }
            }
        }
 private static void LoadNew(PricingVariables data, int positionID, int pricingTypeID)
 {
     using (var db = Database.Open("sqlloco"))
     {
         var vars = db.Query(sqlGetVariablesForNewPackage, positionID, pricingTypeID,
                             LcData.GetCurrentLanguageID(), LcData.GetCurrentCountryID());
         foreach (var r in vars)
         {
             var varValue = new PricingVariableValue {
                 PricingVariableID          = r.PricingVariableID
                 , Value                    = null
                 , ProviderNumberIncluded   = null
                 , ProviderMinNumberAllowed = null
                 , ProviderMaxNumberAllowed = null
                 , Def = PricingVariableDefinition.CreateFromDbRecord(r)
             };
             data[r.InternalName] = varValue;
             // Update index
             data.idIndex[varValue.PricingVariableID] = varValue;
         }
     }
 }