public async Task <IActionResult> Create([Bind("CustomerID,Name,Age,BirthDay,Sex,ProvinceID,DistrictID,Identify,Phone,Email,MetaTitle")] Customer customer)
        {
            if (ModelState.IsValid)
            {
                _context.Add(customer);
                await _context.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            ViewData["ProvinceID"] = new SelectList(_context.Province, "ProvinceID", "ProvinceName", customer.ProvinceID);
            ViewData["ProvinceID"] = new SelectList(_context.Province, "ProvinceID", "ProvinceName", customer.DistrictID);
            return(View(customer));
        }
        public async Task <IActionResult> Create([Bind("RoomID,Name,Image,TypeID,PriceID,Capacity,Floor,MetaTiTle,Status")] Room room)
        {
            if (ModelState.IsValid)
            {
                _context.Add(room);
                await _context.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            ViewData["PriceID"] = new SelectList(_context.Price, "PriceID", "Price1", room.PriceID);
            ViewData["TypeID"]  = new SelectList(_context.Type, "TypeID", "Name", room.TypeID);
            return(View(room));
        }
        public async Task <IActionResult> Create([Bind("ConstractID,Name,RoomID,CustomerID,NumOfMonth,BeginDate,EndDate,MetaTitle,Status")] ContractViewModel contract, long?priceID, int?typeID)
        {
            if (ModelState.IsValid)
            {
                _context.Add(contract);
                await _context.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }

            SelectList type;
            SelectList price;

            if (priceID != null && priceID != 0)
            {
                price = new SelectList(_context.Price, "PriceID", "Price1", priceID);
            }
            else
            {
                price = new SelectList(_context.Price, "PriceID", "Price1");
            }
            if (typeID != null && typeID != 0)
            {
                if (priceID != null && priceID != 0)
                {
                    type = new SelectList(_context.Type.Where(x => x.PriceID == priceID).OrderBy(s => s.Name), "TypeID", "Name", typeID);
                }
                else
                {
                    type = new SelectList(_context.Type.OrderBy(s => s.Name), "TypeID", "Name", typeID);
                }
            }
            else
            {
                if (priceID != null && priceID != 0)
                {
                    type = new SelectList(_context.Type.Where(x => x.PriceID == priceID).OrderBy(s => s.Name), "TypeID", "Name");
                }
                else
                {
                    type = new SelectList(_context.Type.OrderBy(s => s.Name), "TypeID", "Name");
                }
            }

            ViewBag.Types  = type;
            ViewBag.Prices = price;
            return(View(contract));
        }