Exemplo n.º 1
0
        public ProneFullInformation GetProneById(int id)
        {
            ProneFullInformation fullInformation = new ProneFullInformation();

            using (SqlConnection con = new SqlConnection(Connection.String()))
            {
                using (SqlCommand cmd = new SqlCommand("sp_SelectPropertyById", con))
                {
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.Add("@id", SqlDbType.Int).Value = id;
                    con.Open();
                    using (SqlDataReader reader = cmd.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            KonsumatorDbClient konsumatorDbClient = new KonsumatorDbClient();

                            Qytet city                = new Qytet(Convert.ToInt32(reader["qytetID"]), Convert.ToString(reader["qytetEmer"]), 0);
                            PozicionGjeografik geo    = new PozicionGjeografik(Convert.ToDouble(reader["latitude"]), Convert.ToDouble(reader["logitude"]));
                            Adrese             adrese = new Adrese(Convert.ToString(reader["rrugeEmer"]), Convert.ToInt32(reader["nderteseNumer"]), Convert.ToInt32(reader["shkalleNumer"]),
                                                                   Convert.ToInt32(reader["apartamentNumer"]), Convert.ToInt32(reader["zipCode"]));
                            Konsumator            konsumator     = new Konsumator(Convert.ToInt32(reader["idKonsumator"]), Convert.ToDouble(reader["konsumatorRating"]), Convert.ToString(reader["konsumatorPershkrim"]));
                            KonsumatorWithPicture konsumatorFull = konsumatorDbClient.GetKonsumatorById(konsumator.IdKonsumator);
                            KategoriProne         kategori       = new KategoriProne(0, Convert.ToString(reader["kategoriProneEmer"]), Convert.ToString(reader["kategoriPershkrim"]));
                            ProneInfo             info           = new ProneInfo(Convert.ToDouble(reader["proneRating"]));
                            ProneComponent        comp           = new ProneComponent(id, Convert.ToString(reader["proneTitull"]), Convert.ToDouble(reader["proneSiperfaqe"]), Convert.ToInt32(reader["proneNumerDhomash"]), Convert.ToInt32(reader["proneNumerBanjo"]), Convert.ToDouble(reader["pricePerMonth"]), 0, Convert.ToString(reader["pronePicturePath"]));
                            Photo foto = new Photo(Convert.ToString(reader["pronePicture"]), Convert.ToString(reader["pronePicturePath"]));
                            fullInformation = new ProneFullInformation(comp, info, kategori, konsumatorFull, adrese, geo, city, foto);
                        }
                    }
                }
            }
            return(fullInformation);
        }
Exemplo n.º 2
0
        public List <Prone> GetByUserId(int id)
        {
            List <Prone> list = new List <Prone>();

            using (SqlConnection con = new SqlConnection(Connection.String()))
            {
                using (SqlCommand cmd = new SqlCommand("sp_GetPropertiesByUserId", con))
                {
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.Add("@id", SqlDbType.Int).Value = id;

                    con.Open();
                    using (SqlDataReader reader = cmd.ExecuteReader())
                    {
                        if (reader.HasRows)
                        {
                            while (reader.Read())
                            {
                                ProneComponent newProneComp = new ProneComponent(Convert.ToInt32(reader[0]), reader[1].ToString(), Convert.ToDouble(reader[2]), Convert.ToInt32(reader[3]), Convert.ToInt32(reader[4]), Convert.ToDouble(reader["pricePerMonth"]), 0, Convert.ToString(reader["pronePicturePath"]));
                                ProneInfo      pInfo        = new ProneInfo(Convert.ToDouble(reader[9]));
                                Prone          newProne     = new Prone(newProneComp, pInfo);
                                list.Add(newProne);
                            }
                        }
                    }
                }
            }

            return(list);
        }
Exemplo n.º 3
0
        public List <Prone> SearchByCity(Search search)
        {
            List <Prone> list = new List <Prone>();

            using (SqlConnection con = new SqlConnection(Connection.String()))
            {
                using (SqlCommand cmd = new SqlCommand("sp_SearchHouseByCity", con))
                {
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.Add("@city", SqlDbType.VarChar).Value = search.Qyteti;

                    con.Open();
                    using (SqlDataReader reader = cmd.ExecuteReader())
                    {
                        if (reader.HasRows)
                        {
                            while (reader.Read())
                            {
                                ProneComponent newProneComp = new ProneComponent(Convert.ToInt32(reader[0]), reader[1].ToString(), Convert.ToDouble(reader[2]), Convert.ToInt32(reader[3]), Convert.ToInt32(reader[4]), Convert.ToDouble(reader["pricePerMonth"]), 0, Convert.ToString(reader["pronePicturePath"]));
                                ProneInfo      pInfo        = new ProneInfo(Convert.ToDouble(reader[9]));
                                Prone          newProne     = new Prone(newProneComp, pInfo);
                                list.Add(newProne);
                            }
                        }
                    }
                }
            }

            return(list);
        }
 public void Insert(PozicionGjeografik pozicion, Adrese addres, ProneInfo info, ProneComponent component, int idUser, Photo image)
 {
     using (SqlConnection con = new SqlConnection(Connection.String()))
     {
         using (SqlCommand cmd = new SqlCommand("sp_InsertProne", con))
         {
             cmd.CommandType = CommandType.StoredProcedure;
             cmd.Parameters.Add("@latitude", SqlDbType.Real).Value          = pozicion.latitude;
             cmd.Parameters.Add("@logitude", SqlDbType.Real).Value          = pozicion.logitude;
             cmd.Parameters.Add("@rrugeEmer", SqlDbType.VarChar).Value      = addres.rrugeEmer;
             cmd.Parameters.Add("@nderteseNumer", SqlDbType.Int).Value      = addres.nderteseNumer;
             cmd.Parameters.Add("@shkalleNumer", SqlDbType.Int).Value       = addres.shkalleNumer;
             cmd.Parameters.Add("@apartamentNumer", SqlDbType.Int).Value    = addres.apartamentNumer;
             cmd.Parameters.Add("@idQytet", SqlDbType.Int).Value            = addres.idQytet;
             cmd.Parameters.Add("@idShtet", SqlDbType.Int).Value            = addres.idShtet;
             cmd.Parameters.Add("@zipCode", SqlDbType.Int).Value            = addres.zipCode;
             cmd.Parameters.Add("@proneRating", SqlDbType.Decimal).Value    = info.proneRating;
             cmd.Parameters.Add("@idKonsumator", SqlDbType.Int).Value       = idUser;
             cmd.Parameters.Add("@idKategori", SqlDbType.Int).Value         = info.idKategori;
             cmd.Parameters.Add("@proneTitull", SqlDbType.VarChar).Value    = component.ProneTitull;
             cmd.Parameters.Add("@proneSiperfaqe", SqlDbType.Decimal).Value = component.ProneSiperfaqe;
             cmd.Parameters.Add("@proneNumerDhomash", SqlDbType.Int).Value  = component.ProneNumerDhomash;
             cmd.Parameters.Add("@proneNumerBanjo", SqlDbType.Int).Value    = component.ProneNumerBanjo;
             cmd.Parameters.Add("@eLire", SqlDbType.Bit).Value                = component.ELire;
             cmd.Parameters.Add("@pronePicture", SqlDbType.VarChar).Value     = image.profilePicName;
             cmd.Parameters.Add("@pronePicturePath", SqlDbType.VarChar).Value = image.profilePicPath;
             cmd.Parameters.Add("@pricePerMonth", SqlDbType.Decimal).Value    = component.pricePerMonth;
             con.Open();
             cmd.ExecuteNonQuery();
             con.Close();
         }
     }
 }
Exemplo n.º 5
0
 public ActionResult AddProne(ProneInfo info)
 {
     if (Session["Perdorues"] != null)
     {
         TempData["info"] = info;
     }
     else
     {
         Session["Action"]     = "AddProne";
         Session["Controller"] = "Publish";
         return(RedirectToAction("NotLogged", "Login"));
     }
     return(View());
 }
Exemplo n.º 6
0
        public ActionResult PostData(FormCollection collection)
        {
            double latitude = Convert.ToDouble(collection["latitude"]);
            double logitude = Convert.ToDouble(collection["logitude"]);

            Debug.WriteLine(latitude + "  " + logitude);
            PozicionGjeografik pozicion = new PozicionGjeografik(latitude, logitude);
            Photo image = new Photo("Name", "Here");

            String rrugeEmer     = collection["rrugeEmerTxt"];
            int    nderteseNumer = Convert.ToInt32(collection["nderteseNumeTxt"]);
            int    shkalle       = Convert.ToInt32(collection["shkalleNumerTxt"]);
            int    apartament    = Convert.ToInt32(collection["apartamentNumerTxt"]);
            int    shtet         = Convert.ToInt32(collection["shtetSelect"]);
            int    qytet         = Convert.ToInt32(collection["qytetSelect"]);
            int    zipCode       = Convert.ToInt32(collection["zipCodeTxt"]);

            Adrese adrese = new Adrese(rrugeEmer, nderteseNumer, shkalle, apartament, shtet, qytet, zipCode);

            double rating = Convert.ToDouble(collection["ratingTxt"]);
            int    select = Convert.ToInt32(collection["selectCategory"]);

            ProneInfo proneInfo = new ProneInfo(rating, select);

            String proneTitull = collection["proneTitullTxt"];
            double sip         = Convert.ToDouble(collection["proneSiperfaqeTxt"]);
            int    nrDh        = Convert.ToInt32(collection["proneNumerDhomashTxt"]);
            int    nrB         = Convert.ToInt32(collection["proneNumerBanjoTxt"]);
            int    eLire       = Convert.ToInt32(collection["elireSelect"]);
            double cmimPerMuaj = Convert.ToDouble(collection["cmimPerMuajTxt"]);

            ProneComponent prone = new ProneComponent(proneTitull, sip, nrDh, nrB, eLire, cmimPerMuaj);

            try
            {
                Konsumator konsumator = (Konsumator)Session["Perdorues"];
                ProneRegistrationDbClient proneRegDbClient = new ProneRegistrationDbClient();
                proneRegDbClient.Insert(pozicion, adrese, proneInfo, prone, konsumator.IdKonsumator, image);
                ViewBag.ErrorMessage = "Publikimi u krye me sukses!";
                return(Json(new { status = "success", message = ViewBag.ErrorMessage }));
            }
            catch (SqlException ex)
            {
                ViewBag.ErrorMessage = "Publikimi deshtoi! " + ex.Message;
                return(Json(new { status = "error", message = ViewBag.ErrorMessage }));
            }
        }