示例#1
0
 public ActionResult PositionList()
 {
     using (HotelAtrEntity db = new HotelAtrEntity())
     {
         return(View(db.Positions.ToList()));
     }
 }
示例#2
0
 public ActionResult EditRoom(int id)
 {
     using (HotelAtrEntity db = new HotelAtrEntity())
     {
         return(View(db.Rooms.Find(id)));
     }
 }
示例#3
0
 public ActionResult StaffList()
 {
     using (HotelAtrEntity db = new HotelAtrEntity())
     {
         return(View(db.Staffs.ToList()));
     }
 }
示例#4
0
 public ActionResult DetailsStaff(int id)
 {
     using (HotelAtrEntity db = new HotelAtrEntity())
     {
         Staff s = db.Staffs.Find(id);
         return(View(s));
     }
 }
示例#5
0
 public ActionResult DetailsPosition(int id)
 {
     using (HotelAtrEntity db = new HotelAtrEntity())
     {
         Position p = db.Positions.Find(id);
         return(View(p));
     }
 }
示例#6
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"));
     }
 }
示例#7
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"));
     }
 }
示例#8
0
        public ActionResult RoomList()
        {
            List <Room> rooms = new List <Room>();

            using (HotelAtrEntity db = new HotelAtrEntity())
            {
                rooms = db.Rooms.ToList();
            }

            return(View(rooms));
        }
示例#9
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));
 }
示例#10
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));
 }
示例#11
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));
 }
示例#12
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));
 }
示例#13
0
        public ActionResult EditStaff(int id)
        {
            using (HotelAtrEntity db = new HotelAtrEntity())
            {
                Staff staff = db.Staffs.Find(id);

                List <SelectListItem> PositionList =
                    db.Positions
                    .Select(s =>
                            new SelectListItem
                {
                    Text     = s.PositionName,
                    Value    = s.PositionId.ToString(),
                    Selected = staff.PositionId == s.PositionId?true:false
                }).ToList();

                ViewBag.PositionList = PositionList;
                return(View(staff));
            }
        }
示例#14
0
        public ActionResult RoomList()
        {
            //var Browser = HttpContext.Request.;


            List <Room> rooms = new List <Room>();

            using (HotelAtrEntity db = new HotelAtrEntity())
            {
                rooms = db.Rooms.ToList();
            }

            TempData["roomsCount"] = rooms.Count;
            HttpCookie c = new HttpCookie("id");

            c.Value = rooms.Count.ToString();

            HttpContext.Response.Cookies.Add(c);

            return(View(rooms));
        }
示例#15
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));
        }
示例#16
0
        public ActionResult RoomDetails(int id)
        {
            //&_SERVER
            string roomsCount = HttpContext.Response.Cookies["id"].Value;


            Room room = null;

            using (HotelAtrEntity db = new HotelAtrEntity())
            {
                room = db.Rooms.FirstOrDefault(f => f.RoomId == id);
            }


            //ViewBag.Test = "";
            //ViewData["Room"] = room;
            //TempData["roomsCount"]="";

            if (id == 100)
            {
                //Обычные страницы в нете
                return(Redirect("http://google.com"));
            }

            if (id == 101)
            {
                //Обычные страницы в которые лежат в проекте
                return(RedirectPermanent("/Account/Login"));
            }

            if (room != null)
            {
                return(View(room));
            }
            else
            {
                //перенаправление на метод действия
                return(RedirectToAction("RoomList"));
            }
        }