Exemple #1
0
        public List <BathroomType> GetAll()
        {
            List <BathroomType> bathroomTypes = new List <BathroomType>();

            using (var cn = new SqlConnection(Settings.GetConnectionString()))
            {
                SqlCommand cmd = new SqlCommand("BathroomTypesSelectAll", cn);
                cmd.CommandType = CommandType.StoredProcedure;

                cn.Open();

                using (SqlDataReader dr = cmd.ExecuteReader())
                {
                    while (dr.Read())
                    {
                        BathroomType currentRow = new BathroomType();
                        currentRow.BathroomTypeId   = (int)dr["BathroomTypeId"];
                        currentRow.BathroomTypeName = dr["BathroomTypeName"].ToString();

                        bathroomTypes.Add(currentRow);
                    }
                }
            }

            return(bathroomTypes);
        }
        public ActionResult DeleteConfirmed(int id)
        {
            BathroomType bathroomType = db.BathroomTypes.Find(id);

            db.BathroomTypes.Remove(bathroomType);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Exemple #3
0
        private BathroomType PopulateBathTypeFromDataReader(SqlDataReader dr)
        {
            var bathroomType = new BathroomType();

            bathroomType.BathroomTypeId   = (int)dr["BathroomTypeId"];
            bathroomType.BathroomTypeName = dr["BathroomTypeName"].ToString();

            return(bathroomType);
        }
 public ActionResult Edit([Bind(Include = "BathroomTypeID,Type")] BathroomType bathroomType)
 {
     if (ModelState.IsValid)
     {
         db.Entry(bathroomType).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(bathroomType));
 }
        public ActionResult Create([Bind(Include = "BathroomTypeID,Type")] BathroomType bathroomType)
        {
            if (ModelState.IsValid)
            {
                db.BathroomTypes.Add(bathroomType);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(bathroomType));
        }
        // GET: BathroomTypes/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            BathroomType bathroomType = db.BathroomTypes.Find(id);

            if (bathroomType == null)
            {
                return(HttpNotFound());
            }
            return(View(bathroomType));
        }