示例#1
0
        public string createBand(string pstringRequest)
        {
            clsRequest  request  = JsonConvert.DeserializeObject <clsRequest>(pstringRequest);
            clsInfoBand InfoBand = DeserializeJson.DeserializeBandForm(request.Data.ToString());
            clsResponse response = new clsResponse();


            clsInfoUser InfoUser = new clsInfoUser();

            InfoUser.Username = InfoBand.Username;
            FacadeDA.validateUser(InfoUser, ref response);
            if (!response.Success)                       //not existing username
            {
                response            = new clsResponse(); //clear the response
                InfoBand.Salt       = clsHasher.genSalt();
                InfoBand.SaltHashed = clsHasher.hashPassword(InfoBand.Password, InfoBand.Salt);
                InfoBand            = FacadeDA.createBand(InfoBand, ref response);

                //save image here!
                ArchiveManager.saveUserImage(InfoBand.Id, InfoBand.Picture, ref response);
                InfoUser.Salt       = null; // clear the object before sending
                InfoUser.SaltHashed = null; // clear the object before sending
            }
            else
            {
                //error info
                response.Success = false;
                response.Message = "Existing Username";
                response.Code    = 3;
            }

            response.Data = serializer.Serialize(InfoBand);
            return(serializer.Serialize(response));
        }
示例#2
0
        public string updateBand(string pstringRequest, int pintFanId)
        {
            clsRequest  request  = JsonConvert.DeserializeObject <clsRequest>(pstringRequest);
            clsInfoBand InfoBand = DeserializeJson.DeserializeBandForm(request.Data);

            InfoBand.Id = request.Id;
            clsResponse response = new clsResponse();

            if (InfoBand.Id == pintFanId)
            {
                InfoBand = FacadeDA.updateBand(InfoBand, ref response);
                if (InfoBand.Picture.CompareTo("") != 0) // change image
                {
                    ArchiveManager.updateUserImage(InfoBand.Id, InfoBand.Picture, ref response);
                }
            }
            else
            {
                //error info
                response.Success = false;
                response.Message = "Invalid Operation";
                response.Code    = 401;
            }
            //Data = null
            return(serializer.Serialize(response));
        }
示例#3
0
        internal static clsInfoBand parseBandInfo(string json)
        {
            clsResponse Response = parseResponse(json);
            dynamic     data     = JObject.Parse(Response.Data);

            clsInfoBand infoBand = JsonConvert.DeserializeObject <clsInfoBand>(Convert.ToString(data));

            return(infoBand);
        }
示例#4
0
        public string checkHashtag(string pstringHashtag)
        {
            clsInfoBand InfoBand = new clsInfoBand();

            InfoBand.Hashtag = pstringHashtag;
            clsResponse response = new clsResponse();

            FacadeDA.validateHashTag(InfoBand, ref response);
            //Data = null
            return(serializer.Serialize(response));
        }
示例#5
0
        public string getBandInfo(int pintBandId)
        {
            clsInfoBand InfoBand = new clsInfoBand();
            clsResponse response = new clsResponse();

            FacadeDA.getBandInfo(ref InfoBand, ref response, pintBandId);
            FacadeDA.getGenresBand(ref InfoBand, ref response, pintBandId);
            FacadeDA.getMembersInfo(ref InfoBand, ref response, pintBandId);


            response.Data = serializer.Serialize(InfoBand);
            return(serializer.Serialize(response));
        }
示例#6
0
 public void validateHashTag(clsInfoBand pclsInfoBand, ref clsResponse pclsResponse)
 {
     try
     {
         BandRead.validateHashTag(pclsInfoBand, ref pclsResponse);
     }
     catch
     {
         pclsResponse.Code    = 007;
         pclsResponse.Success = false;
         pclsResponse.Message = "Internal Error";
     }
 }
示例#7
0
        public static void Main()
        {
            System.Diagnostics.Stopwatch sw = Stopwatch.StartNew();
            clsFacadeDA a = new clsFacadeDA();
            clsForm     b = new clsForm();
            clsResponse c = new clsResponse();
            Serializer  j = new Serializer();
            clsInfoBand p = new clsInfoBand();

            Console.WriteLine(j.Serialize(a.getAllGenres(a.getAllGenders(b, ref c), ref c)));
            Console.WriteLine(sw.ElapsedMilliseconds);
            sw.Stop();
            Console.ReadKey();
        }
示例#8
0
 public void validateHashTag(clsInfoBand pclsInfoBand, ref clsResponse pclsResponse)
 {
     try
     {
         SqlCommand cmd = new SqlCommand("myFan.SP_ExistsHashtag", conn);
         cmd.CommandType = System.Data.CommandType.StoredProcedure;
         cmd.Parameters.Add("@Hashtag", System.Data.SqlDbType.VarChar).Value = pclsInfoBand.Hashtag;
         conn.Open();
         SqlDataReader result = cmd.ExecuteReader();
         result.Read();
         Console.WriteLine("entre");
         if (result.HasRows == true)
         {
             if (result["Hagstag"].ToString().Equals("True"))
             {
                 pclsResponse.Code    = 0;
                 pclsResponse.Message = "Done";
                 pclsResponse.Success = true;
             }
             else
             {
                 pclsResponse.Code    = 3;
                 pclsResponse.Message = "Incorrect HashTag";
                 pclsResponse.Success = false;
             }
         }
         else
         {
             pclsResponse.Code    = 3;
             pclsResponse.Message = "Incorrect HashTag";
             pclsResponse.Success = false;
         }
     }
     catch (SqlException ex)
     {
         pclsResponse.Code    = 1;
         pclsResponse.Success = false;
         pclsResponse.Message = "Error while procesing your request.";
     }
     catch (Exception ex)
     {
         pclsResponse.Code    = 2;
         pclsResponse.Success = false;
         pclsResponse.Message = "Unexpected error.";
     }
     finally
     {
         conn.Close();
     }
 }
示例#9
0
 public clsInfoBand createBand(clsInfoBand pclsInfoBand, ref clsResponse pclsResponse)
 {
     try
     {
         return(BandWrite.createBand(pclsInfoBand, ref pclsResponse));
     }
     catch
     {
         pclsResponse.Code    = 007;
         pclsResponse.Success = false;
         pclsResponse.Message = "Internal Error";
         return(pclsInfoBand);// cambiar x error
     }
 }
示例#10
0
        public clsInfoBand createBand(clsInfoBand pclsInfoBand, ref clsResponse pclsResponse)
        {
            try
            {
                SqlCommand cmd = new SqlCommand("myFan.SP_CrearBanda", conn);
                cmd.CommandType = System.Data.CommandType.StoredProcedure;
                cmd.Parameters.Add("@strLoginName", System.Data.SqlDbType.VarChar).Value          = pclsInfoBand.Username;
                cmd.Parameters.Add("@strNombre", System.Data.SqlDbType.VarChar).Value             = pclsInfoBand.Name;
                cmd.Parameters.Add("@strGeneros", System.Data.SqlDbType.VarChar).Value            = String.Join(",", pclsInfoBand.CodGenres);
                cmd.Parameters.Add("@strBiografia", System.Data.SqlDbType.VarChar).Value          = pclsInfoBand.Biography;
                cmd.Parameters.Add("@dtAnoCreacion", System.Data.SqlDbType.Date).Value            = pclsInfoBand.DateCreation;
                cmd.Parameters.Add("@intPais", System.Data.SqlDbType.VarChar).Value               = pclsInfoBand.Country;
                cmd.Parameters.Add("@strIntegrantes", System.Data.SqlDbType.VarChar).Value        = String.Join(",", pclsInfoBand.Members);
                cmd.Parameters.Add("@strHashTag", System.Data.SqlDbType.VarChar).Value            = pclsInfoBand.Hashtag;
                cmd.Parameters.Add("@strSalt", System.Data.SqlDbType.VarChar).Value               = pclsInfoBand.Salt;
                cmd.Parameters.Add("@strSaltHashedPassword", System.Data.SqlDbType.VarChar).Value = pclsInfoBand.SaltHashed;
                SqlParameter message = cmd.Parameters.Add("@strMessageError", SqlDbType.VarChar, 256);
                message.Direction = ParameterDirection.Output;
                SqlParameter cod = cmd.Parameters.Add("@strCodError", SqlDbType.VarChar, 4);
                cod.Direction = ParameterDirection.Output;
                SqlParameter id = cmd.Parameters.Add("@intCodUserReturn", SqlDbType.Int);
                id.Direction = ParameterDirection.Output;
                conn.Open();

                cmd.ExecuteNonQuery();

                pclsInfoBand.Id      = Convert.ToInt32(id.Value);
                pclsResponse.Code    = Convert.ToInt32(cod.Value.ToString());
                pclsResponse.Message = message.Value.ToString();
                pclsResponse.Success = true;
            }
            catch (SqlException ex)
            {
                pclsResponse.Code    = 1;
                pclsResponse.Success = false;
                pclsResponse.Message = "Error while procesing your request.";
            }
            catch (Exception ex)
            {
                pclsResponse.Code    = 2;
                pclsResponse.Success = false;
                pclsResponse.Message = "Unexpected error.";
            }
            finally
            {
                conn.Close();
            }
            return(pclsInfoBand);
        }
示例#11
0
        public clsInfoBand updateBand(clsInfoBand pclsInfoBand, ref clsResponse pclsResponse)
        {
            try
            {
                SqlCommand cmd = new SqlCommand("myFan.SP_ActualizarBanda", conn);
                cmd.CommandType = System.Data.CommandType.StoredProcedure;
                cmd.Parameters.Add("@intCodUser", System.Data.SqlDbType.Int).Value         = pclsInfoBand.Id;
                cmd.Parameters.Add("@strNombre", System.Data.SqlDbType.VarChar).Value      = pclsInfoBand.Name;
                cmd.Parameters.Add("@strGeneros", System.Data.SqlDbType.VarChar).Value     = String.Join(",", pclsInfoBand.CodGenres);
                cmd.Parameters.Add("@strIntegrantes", System.Data.SqlDbType.VarChar).Value = String.Join(",", pclsInfoBand.Members);
                cmd.Parameters.Add("@dtAnoCreacion", System.Data.SqlDbType.Date).Value     = pclsInfoBand.DateCreation;
                cmd.Parameters.Add("@intUbicacion", System.Data.SqlDbType.Int).Value       = pclsInfoBand.Country;
                cmd.Parameters.Add("@strHashTag", System.Data.SqlDbType.VarChar).Value     = pclsInfoBand.Hashtag;
                SqlParameter message = cmd.Parameters.Add("@strMessageError", SqlDbType.VarChar, 256);
                message.Direction = ParameterDirection.Output;
                SqlParameter cod = cmd.Parameters.Add("@strCodError", SqlDbType.VarChar, 4);
                cod.Direction = ParameterDirection.Output;

                conn.Open();
                cmd.ExecuteNonQuery();
                pclsResponse.Code    = 0;
                pclsResponse.Message = "Done";
                pclsResponse.Success = true;
            }
            catch (SqlException ex)
            {
                pclsResponse.Code    = 1;
                pclsResponse.Success = false;
                pclsResponse.Message = "Error while procesing your request.";
            }
            catch (Exception ex)
            {
                pclsResponse.Code    = 2;
                pclsResponse.Success = false;
                pclsResponse.Message = "Unexpected error.";
            }
            finally
            {
                conn.Close();
            }
            return(pclsInfoBand);
        }
示例#12
0
        public void getBandInfo(ref clsInfoBand pclsInfoBand, ref clsResponse pclsResponse, int pintUserID)
        {
            try
            {
                SqlCommand cmd = new SqlCommand("myFan.SP_GetBandProfile", conn);
                cmd.CommandType = System.Data.CommandType.StoredProcedure;
                cmd.Parameters.Add("@UserCode", System.Data.SqlDbType.Int).Value = pintUserID;
                conn.Open();
                SqlDataReader result = cmd.ExecuteReader();
                while (result.Read())
                {
                    pclsInfoBand.Username  = result["LoginName"].ToString();
                    pclsInfoBand.Name      = result["NombreBanda"].ToString();
                    pclsInfoBand.Country   = result["Pais"].ToString();
                    pclsInfoBand.Hashtag   = result["Hashtag"].ToString();
                    pclsInfoBand.Biography = result["Biografia"].ToString();
                    DateTime dat = Convert.ToDateTime(result["AnoCreacion"].ToString(), CultureInfo.InvariantCulture);
                    pclsInfoBand.DateCreation = dat.ToString("yyyy") + "-" + dat.ToString("MM") + '-' + dat.ToString("dd");
                }

                pclsResponse.Code    = 0;
                pclsResponse.Message = "Done";
                pclsResponse.Success = true;
            }
            catch (SqlException ex)
            {
                pclsResponse.Code    = 1;
                pclsResponse.Success = false;
                pclsResponse.Message = "Error while procesing your request.";
            }
            catch (Exception ex)
            {
                pclsResponse.Code    = 2;
                pclsResponse.Success = false;
                pclsResponse.Message = "Unexpected error.";
            }
            finally
            {
                conn.Close();
            }
        }
示例#13
0
        public clsInfoBand DeserializeBandForm(string pstringData)
        {
            clsInfoBand InfoBand = new clsInfoBand();
            dynamic     data     = JObject.Parse(pstringData);


            InfoBand.Active       = true;
            InfoBand.DateCreation = Convert.ToString(data.DateCreation);
            InfoBand.Country      = Convert.ToString(data.Country);
            InfoBand.Hashtag      = Convert.ToString(data.Hashtag);
            InfoBand.CodGenres    = JsonConvert.DeserializeObject <List <int> >(Convert.ToString(data.Genres));
            //InfoBand.Genres = JsonConvert.DeserializeObject<List<string>>(Convert.ToString(data.Genres));
            InfoBand.Name      = Convert.ToString(data.Name);
            InfoBand.Members   = JsonConvert.DeserializeObject <List <string> >(Convert.ToString(data.Members));
            InfoBand.Biography = Convert.ToString(data.Biography);
            InfoBand.Password  = Convert.ToString(data.Password);
            InfoBand.Username  = Convert.ToString(data.Username);
            InfoBand.Picture   = Convert.ToString(data.Picture);

            return(InfoBand);
        }
示例#14
0
 public void getGenresBand(ref clsInfoBand pclsInfoBand, ref clsResponse pclsResponse, int pintUserCode)
 {
     try
     {
         SqlCommand cmd = new SqlCommand("myFan.SP_GetGenresByUser", conn);
         cmd.CommandType = System.Data.CommandType.StoredProcedure;
         cmd.Parameters.Add("@intUserCode", System.Data.SqlDbType.Int).Value = pintUserCode;
         conn.Open();
         SqlDataReader result       = cmd.ExecuteReader();
         List <String> tmpGenres    = new List <string>();
         List <int>    tmpCodGenres = new List <int>();
         while (result.Read())
         {
             tmpGenres.Add(result["DescripcionGenero"].ToString());
             tmpCodGenres.Add(Convert.ToInt32(result["CodigoGenero"].ToString()));
         }
         pclsInfoBand.Genres    = tmpGenres;
         pclsInfoBand.CodGenres = tmpCodGenres;
         pclsResponse.Code      = 0;
         pclsResponse.Message   = "Done";
         pclsResponse.Success   = true;
     }
     catch (SqlException ex)
     {
         pclsResponse.Code    = 1;
         pclsResponse.Success = false;
         pclsResponse.Message = "Error while procesing your request.";
     }
     catch (Exception ex)
     {
         pclsResponse.Code    = 2;
         pclsResponse.Success = false;
         pclsResponse.Message = "Unexpected error.";
     }
     finally
     {
         conn.Close();
     }
 }
示例#15
0
        public void getMembersInfo(ref clsInfoBand pclsInfoBand, ref clsResponse pclsResponse, int pintUserID)
        {
            try
            {
                SqlCommand cmd = new SqlCommand("myFan.SP_GetMemberBand", conn);
                cmd.CommandType = System.Data.CommandType.StoredProcedure;
                cmd.Parameters.Add("@intCodBand", System.Data.SqlDbType.Int).Value = 0;
                cmd.Parameters.Add("@intCodUser", System.Data.SqlDbType.Int).Value = pintUserID;
                conn.Open();
                SqlDataReader result  = cmd.ExecuteReader();
                List <String> members = new List <string>();

                while (result.Read())
                {
                    members.Add(result["Nombre"].ToString());
                }

                pclsInfoBand.Members = members;
                pclsResponse.Code    = 0;
                pclsResponse.Message = "Done";
                pclsResponse.Success = true;
            }
            catch (SqlException ex)
            {
                pclsResponse.Code    = 1;
                pclsResponse.Success = false;
                pclsResponse.Message = "Error while procesing your request.";
            }
            catch (Exception ex)
            {
                pclsResponse.Code    = 2;
                pclsResponse.Success = false;
                pclsResponse.Message = "Unexpected error.";
            }
            finally
            {
                conn.Close();
            }
        }
示例#16
0
        public static void Main()
        {
            clsInfoBand b = new clsInfoBand();

            b.Username     = "******";
            b.Name         = "canesota";
            b.CodGenres    = new List <int>(new int[] { 1, 2 });
            b.Members      = new List <string>(new string[] { "Panochon69", "PAnochote69" });
            b.DateCreation = "1-2-2016";
            b.Biography    = "Listo";
            b.Country      = "9";
            b.Hashtag      = "@canepicha";
            b.Id           = 133;


            clsBandWrite d = new clsBandWrite();
            clsResponse  f = new clsResponse();

            d.updateBand(b, ref f);
            Console.WriteLine(f.Message);
            Console.ReadKey();
        }
示例#17
0
 public clsInfoBand updateBand(clsInfoBand pclsInfoBand, ref clsResponse pclsResponse)
 {
     return(BandWrite.updateBand(pclsInfoBand, ref pclsResponse));
 }
示例#18
0
 public void getGenresBand(ref clsInfoBand pclsInfoBand, ref clsResponse pclsResponse, int pintUserCode)
 {
     BandRead.getGenresBand(ref pclsInfoBand, ref pclsResponse, pintUserCode);
 }
示例#19
0
 public void getMembersInfo(ref clsInfoBand pclsInfoBand, ref clsResponse pclsResponse, int pintUserID)
 {
     BandRead.getMembersInfo(ref pclsInfoBand, ref pclsResponse, pintUserID);
 }
示例#20
0
 public void validateHashTag(clsInfoBand pclsInfoBand, ref clsResponse pclsResponse)
 {
     BandDA.validateHashTag(pclsInfoBand, ref pclsResponse);
 }
示例#21
0
 public clsInfoBand createBand(clsInfoBand pclsInfoBand, ref clsResponse pclsResponse)
 {
     return(BandDA.createBand(pclsInfoBand, ref pclsResponse));
 }
示例#22
0
 public void getBandInfo(ref clsInfoBand pclsInfoBand, ref clsResponse pclsResponse, int pintUserID)
 {
     BandDA.getBandInfo(ref pclsInfoBand, ref pclsResponse, pintUserID);
 }