public IEnumerable <RoomCustomerViewModel> GetAll()
        {
            List <RoomCustomerViewModel> Room = new List <RoomCustomerViewModel>();

            foreach (var item in db.CustomerRooms)
            {
                RoomCustomerViewModel obj = new RoomCustomerViewModel();

                obj.id      = item.id;
                obj.EndData = item.EndData;
                Room.Add(obj);
            }
            return(Room);
        }
        public JsonResult CustomerRoom(RoomCustomerViewModel RoomCustomer)
        {
            int A = RC.Add(RoomCustomer);

            TempData["Roomcustomerid"] = A;

            if (A != 0)
            {
                return(Json("success", JsonRequestBehavior.AllowGet));
            }
            else
            {
                return(Json("success", JsonRequestBehavior.AllowGet));
            }
        }
        public IEnumerable <RoomCustomerViewModel> GtById(int id)
        {
            List <RoomCustomerViewModel> RoomCustomer = new List <RoomCustomerViewModel>();

            foreach (var item in db.CustomerRooms.Where(x => x.CustomerIdfk == id))
            {
                RoomCustomerViewModel obj = new RoomCustomerViewModel();
                obj.id           = item.id;
                obj.CustomerIdfk = item.CustomerIdfk;
                obj.Name         = item.Customer.CustomerName;
                obj.startDate    = item.startDate.ToString();
                obj.EndData      = item.EndData.ToString();
                obj.RoomName     = item.Room.RoomNo;

                RoomCustomer.Add(obj);
            }
            return(RoomCustomer);
        }
Exemplo n.º 4
0
        // GET: Rooms/Details/5
        public async Task <IActionResult> Details(int?id, int?customerid)
        {
            if (id == null)
            {
                return(NotFound());
            }

            var room = await _context.Room
                       .Include(r => r.RoomStatus)
                       .Include(r => r.RoomType)
                       .FirstOrDefaultAsync(m => m.RoomId == id);

            if (room == null)
            {
                return(NotFound());
            }
            Customer customer = null;

            if (customerid != null)
            {
                customer = await _context.Customer
                           .FirstOrDefaultAsync(m => m.CustomerId == customerid);
            }


            if (room == null)
            {
                return(NotFound());
            }

            var roomCustomerVM = new RoomCustomerViewModel
            {
                Room     = room,
                Customer = customer
            };

            return(View(roomCustomerVM));
        }
        public int Add(RoomCustomerViewModel RoomCustomer)
        {
            var roomid = db.CustomerRooms.Where(x => x.RoomIdfk == RoomCustomer.RoomIdfk).FirstOrDefault();

            if (roomid != null)
            {
                return(0);
            }
            else
            {
                CustomerRoom obj = new CustomerRoom();
                obj.id           = RoomCustomer.id;
                obj.CustomerIdfk = RoomCustomer.CustomerIdfk;
                obj.startDate    = RoomCustomer.startDate;
                obj.EndData      = RoomCustomer.EndData;
                obj.RoomIdfk     = RoomCustomer.RoomIdfk;
                db.CustomerRooms.Add(obj);
                obj.IsPase = true;

                db.SaveChanges();
                return(RoomCustomer.id);
            }
        }