Ejemplo n.º 1
0
 public ActionResult DeleteStaff(int id)
 {
     using (HotelAtrEntity db = new HotelAtrEntity())
     {
         Staff s = db.Staffs.Find(id);
         db.Staffs.Remove(s);
         db.SaveChanges();
         return(RedirectToAction("StaffList"));
     }
 }
Ejemplo n.º 2
0
 public ActionResult DeletePosition(int id)
 {
     using (HotelAtrEntity db = new HotelAtrEntity())
     {
         Position p = db.Positions.Find(id);
         db.Positions.Remove(p);
         db.SaveChanges();
         return(RedirectToAction("PositionList"));
     }
 }
Ejemplo n.º 3
0
 public ActionResult AddStaff(Staff staff)
 {
     if (ModelState.IsValid)
     {
         using (HotelAtrEntity db = new HotelAtrEntity())
         {
             db.Staffs.Add(staff);
             db.SaveChanges();
         }
         return(RedirectToAction("StaffList"));
     }
     return(View(staff));
 }
Ejemplo n.º 4
0
 public ActionResult AddPosition(Position position)
 {
     if (ModelState.IsValid)
     {
         using (HotelAtrEntity db = new HotelAtrEntity())
         {
             db.Positions.Add(position);
             db.SaveChanges();
         }
         return(RedirectToAction("PositionList"));
     }
     return(View(position));
 }
Ejemplo n.º 5
0
 public ActionResult EditStaff(Staff staff)
 {
     if (ModelState.IsValid)
     {
         using (HotelAtrEntity db = new HotelAtrEntity())
         {
             Staff s = db.Staffs.Find(staff.StaffId);
             s.StaffId = staff.StaffId;
             //db.Entry(p).State=EntityState.Modified;
             db.SaveChanges();
         }
         return(RedirectToAction("StaffsList"));
     }
     return(View(staff));
 }
Ejemplo n.º 6
0
 public ActionResult EditPosition(Position position)
 {
     if (ModelState.IsValid)
     {
         using (HotelAtrEntity db = new HotelAtrEntity())
         {
             Position p = db.Positions.Find(position.PositionId);
             p.PositionName = position.PositionName;
             //db.Entry(p).State=EntityState.Modified;
             db.SaveChanges();
         }
         return(RedirectToAction("PositionList"));
     }
     return(View(position));
 }
Ejemplo n.º 7
0
        public ActionResult AddRoomType(RoomType roomType, string Action)
        {
            if (Action == "add")
            {
                using (HotelAtrEntity db = new HotelAtrEntity())
                {
                    db.RoomTypes.Add(roomType);
                    //db.SaveChanges();
                }
            }
            else if (Action == "edit")
            {
                using (HotelAtrEntity db = new HotelAtrEntity())
                {
                    RoomType rt = db.RoomTypes.Find(roomType.RoomTypeId);
                    db.Entry(rt).State = EntityState.Modified;
                    db.SaveChanges();
                }
            }

            //RoomType rt = new RoomType();
            //rt.Name = "Double room";
            //rt.RoomTypeDescription = "Some XDescription (Double room)";


            //List<SelectListItem> lists = new List<SelectListItem>();
            //lists.Add(new SelectListItem()
            //{
            //    Text = "Almaty", Value = "ALA"
            //});
            //lists.Add(new SelectListItem()
            //{
            //    Text = "Astana", Value = "TSN",
            //    Selected = true
            //});

            //ViewBag.ContryList = lists;

            return(View(roomType));
        }