Ejemplo n.º 1
0
        public UserDTO GetProfileByPhone(string phoneNumber, string lang, int userType)
        {
            UserQuery userQuery = new UserQuery(language);

            System.Data.DataTable dataTable;

            if (userType == 1)
            {
                dataTable = conn_db.ReadTable(userQuery.GetProfileByPhoneForPerson(phoneNumber));
            }
            else
            {
                dataTable = conn_db.ReadTable(userQuery.GetProfileByPhoneForWorkshop(phoneNumber, lang));
            }

            if (dataTable.Rows.Count == 0)
            {
                throw new EmptyViewException(language);
            }

            UserDTO profile = new UserDTO();


            profile.user_id     = dataTable.Rows[0]["USER_ID"] is DBNull ? 0 : Convert.ToInt32(dataTable.Rows[0]["USER_ID"]);
            profile.accessToken = dataTable.Rows[0]["ACCESSTOKEN"].ToString();
            profile.countryCode = dataTable.Rows[0]["COUNTRYCODE"] is DBNull ? 0 : Convert.ToInt32(dataTable.Rows[0]["COUNTRYCODE"]);
            profile.phoneNumber = dataTable.Rows[0]["PHONENUMBER"].ToString();
            profile.userType    = dataTable.Rows[0]["USERTYPE"] is DBNull ? 0 : Convert.ToInt32(dataTable.Rows[0]["USERTYPE"]);
            profile.userImage   = dataTable.Rows[0]["USERIMAGE"].ToString();

            profile.rating    = dataTable.Rows[0]["RATING"] is DBNull ? 0 : Convert.ToDouble(dataTable.Rows[0]["RATING"]);
            profile.firstName = dataTable.Rows[0]["FIRSTNAME"].ToString();
            profile.lastName  = dataTable.Rows[0]["LASTNAME"].ToString();


            profile.shopNumber = dataTable.Rows[0]["STORE_NUMBER"] is DBNull ? 0 : Convert.ToInt32(dataTable.Rows[0]["STORE_NUMBER"]);
            profile.shopName   = dataTable.Rows[0]["STORE_NAME"].ToString();
            profile.cityId     = dataTable.Rows[0]["CITYID"] is DBNull ? 0 : Convert.ToInt32(dataTable.Rows[0]["CITYID"]);
            profile.cityName   = dataTable.Rows[0]["CITY_NAME"].ToString();
            profile.address    = dataTable.Rows[0]["ADDRESS"].ToString();
            profile.Lat        = dataTable.Rows[0]["LAT"] is DBNull ? 0 : Convert.ToDouble(dataTable.Rows[0]["LAT"]);
            profile.Lng        = dataTable.Rows[0]["LNG"] is DBNull ? 0 : Convert.ToDouble(dataTable.Rows[0]["LNG"]);



            return(profile);
        }