Пример #1
0
 public IActionResult EditHotelChain(String Hcid)
 {
     if (isEmployee())
     {
         Hotelchain hotelChain = getHotelChain(Convert.ToInt32(Hcid));
         HotelChainViewModel model = new HotelChainViewModel(_context, hotelChain);
         return View(model);
     }
     else
     {
         return RedirectToAction("AccessDenied", "Account");
     }
 }
Пример #2
0
 private Hotelchain getHotelChain(int Hcid)
 {
     try
     {
         Hotelchain hotelChain = _context.Hotelchain.FromSql("SELECT * FROM eHotel.hotelchain WHERE Hcid={0}", parameters: Hcid).ToList()[0];
         return hotelChain;
     }
     catch (PostgresException ex)
     {
         //TODO better error handling
         TempData["ErrorMessage"] = Constants.GENERICPOSTGREERROR;
         return null;
     }
 }
Пример #3
0
 private Boolean updateHotelChain(Hotelchain model)
 {
     Object[] insertArray = new object[] { model.HotelChainName, model.StreetNumber, model.StreetName,
         model.AptNumber, model.City,model.HcState,model.Zip,model.Hcid };
     try
     {
         _context.Database.ExecuteSqlCommand("UPDATE eHotel.hotelchain SET hotel_chain_name={0}, street_number={1}, street_name={2}, apt_number={3}, city={4}, hc_state={5}, zip={6} WHERE hcid={7}", parameters: insertArray);
         return true;
     }
     catch (PostgresException ex)
     {
         //TODO better error handling
         TempData["ErrorMessage"] = Constants.GENERICPOSTGREERROR;
         return false;
     }
 }
Пример #4
0
        public IActionResult DeleteHotelChain([FromBody]Hotelchain data)
        {
            if (isEmployee())
            {
                if (deleteHotelChain(Convert.ToInt32(data.Hcid)))
                {
                    return Json("Success");
                }
                else
                {
                    return Json("Error: Could not delete the hotel");
                }
            }
            else
            {
                return RedirectToAction("AccessDenied", "Account");
            }

        }
Пример #5
0
 private Boolean insertHotelChain(Hotelchain model)
 {
     try
     {
         Object[] insertArray = new object[] { model.HotelChainName, model.StreetNumber, model.StreetName,
         model.AptNumber, model.City, model.HcState,model.Zip, model.NumHotels };
         _context.Database.ExecuteSqlCommand(
            "INSERT INTO eHotel.hotelchain (hotel_chain_name,street_number,street_name,apt_number,city,hc_state,zip,num_hotels)" +
            "VALUES ({0},{1},{2},{3},{4},{5},{6},{7})",
            parameters: insertArray);
         return true;
     }
     catch (PostgresException ex)
     {
         //TODO better error handling
         TempData["ErrorMessage"] = Constants.GENERICPOSTGREERROR;
         return false;
     }
 }