Пример #1
0
 public IActionResult EditHotelChain(HotelChainViewModel model)
 {
     if (isEmployee())
     {
         ModelState.Remove("PhoneAdd");
         ModelState.Remove("EmailAdd");
         if (ModelState.IsValid)
         {
             Boolean insertResult = updateHotelChain(convertModelToHotelChain(model));
             if (insertResult)
             {
                 TempData["SuccessMessage"] = "Hotel chain updated";
                 return RedirectToAction("ManageHotelChains");
             }
             else
             {
                 ModelState.AddModelError(string.Empty, TempData["ErrorMessage"].ToString());
             }
         }
         // If we got this far, something failed, redisplay form
         model.initModel(_context, Convert.ToInt32(model.Hcid));
         return View(model);
     }
     else
     {
         return RedirectToAction("AccessDenied", "Account");
     }
 }
Пример #2
0
 public IActionResult CreateHotelChain(HotelChainViewModel model)
 {
     if (isEmployee())
     {
         if (ModelState.IsValid)
         {
             Boolean insertResult = createHotelChain(model);
             if (insertResult)
             {
                 TempData["SuccessMessage"] = "Hotel chain created";
                 return RedirectToAction("ManageHotelChains");
             }
             else
             {
                 ModelState.AddModelError(string.Empty, TempData["ErrorMessage"].ToString());
             }
         }
         // If we got this far, something failed, redisplay form
         return View(model);
     }
     else
     {
         return RedirectToAction("AccessDenied", "Account");
     }
 }
Пример #3
0
 public IActionResult CreateHotelChain()
 {
     if (isEmployee())
     {
         HotelChainViewModel model = new HotelChainViewModel();
         return View(model);
     }
     else
     {
         return RedirectToAction("AccessDenied", "Account");
     }
 }
Пример #4
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");
     }
 }
Пример #5
0
 private Hotelchain convertModelToHotelChain(HotelChainViewModel model)
 {
     return new Hotelchain
     {
         Hcid = Convert.ToInt32(model.Hcid),
         HotelChainName = model.HotelChainName,
         NumHotels = 0,
         StreetNumber = model.StreetNumber,
         StreetName = model.StreetName,
         AptNumber = model.AptNumber,
         City = model.City,
         HcState = model.State,
         Zip = model.Zip
     };
 }
Пример #6
0
        /// <summary>
        /// Return the mapped HotelChains viewmodel
        /// </summary>
        /// <param name="hotelChainList"></param>
        /// <returns></returns>
        public static BaseResult <List <HotelChainViewModel> > MapHotelChains(BaseResult <List <HotelChain> > hotelChainList)
        {
            BaseResult <List <HotelChainViewModel> > responseModelList = new BaseResult <List <HotelChainViewModel> >();
            List <HotelChainViewModel> modelList = new List <HotelChainViewModel>();

            foreach (var item in hotelChainList.Result)
            {
                HotelChainViewModel model = new HotelChainViewModel
                {
                    HotelChainId   = item.Id,
                    HotelChainName = item.Name
                };
                modelList.Add(model);
            }
            responseModelList.Result = modelList;
            if (responseModelList.IsError)
            {
                responseModelList.Message = "Error in request";
            }
            return(responseModelList);
        }
Пример #7
0
 private Boolean createHotelChain(HotelChainViewModel model)
 {
     return insertHotelChain(convertModelToHotelChain(model));
 }