Example #1
0
        public string DeleteAlojamento([FromBody] alojamento aloj)
        {
            string        result = "nok";
            SqlConnection conn   = new SqlConnection(TTOrcamentos2.Properties.Settings.Default.ConnectionString);
            SqlCommand    cmd    = new SqlCommand("deleteAlojamento", conn);

            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.Add("@alojamentoidv", SqlDbType.VarChar).Value = aloj.alojamentoidv;
            try
            {
                conn.Open();

                var t = cmd.ExecuteScalar();
                result = "ok";
            }
            catch (Exception ex)
            {
                throw new Exception("Execption adding account. " + ex.Message);
            }
            finally
            {
                conn.Close();
            }
            return(result);
        }
Example #2
0
        public alojamento SearchHouseId(string id)
        {
            alojamento r = new alojamento();

            int houseId = 0;

            int.TryParse(id, out houseId);
            if (SearchContract(houseId))
            {
                using (ImoEstudanteEntities db = new ImoEstudanteEntities())
                {
                    r = db.alojamentoes.Where(x => x.idAlojamento == houseId).First();
                }
            }

            return(r);
        }
Example #3
0
        public bool AddHouse(alojamento aluguerData)
        {
            using (ImoEstudanteEntities db = new ImoEstudanteEntities())
            {
                try
                {
                    List <alojamento> p  = db.alojamentoes.ToList();
                    int        i         = p.Count;
                    alojamento dbAluguer = new alojamento();


                    db.alojamentoes.Add(dbAluguer);
                    db.SaveChanges();


                    return(true);
                }
                catch
                {
                    return(false);
                }
            }
        }