Example #1
0
        public async Task <Response <bool> > AddHotel(Model.Add.Hotel hotel)
        {
            var response = _repository.AddHotel(hotel);

            if (response > 0)
            {
                return(new Response <bool>(true));
            }
            if (response == -1)
            {
                return(new Response <bool>(false, Infrastructure.Utils.Enums.ResponseCodes.AlreadyExist, "Hotel Already Exists"));
            }
            return(new Response <bool>(false, Infrastructure.Utils.Enums.ResponseCodes.BadRequest, "Saving of Hotel information failed."));
        }
Example #2
0
        public ActionResult Create(EditHotelViewModel ehvm)
        {
            //if (ModelState.IsValid)
            {
                try
                {
                    Hotel h = new Hotel();
                    hotelRepo.AddHotel(h);
                    Context x = hotelRepo.getContext();
                    MapToHotel(ehvm, h, x);


                    x.SaveChanges();
                    TempData["message"] = String.Format("Hotel {0} werd gecreƫerd", h.Name);
                    return(RedirectToAction("Index"));
                }
                catch (Exception ex)
                {
                    ModelState.AddModelError("", ex.Message);
                }
            }
            // http policy requires to fill the list again after the post
            ehvm.Branch = branchRepo.FindAll().Select(t => new SelectListItem
            {
                Value = t.Name,
                Text  = t.Name
            });
            ehvm.ContactPerson = contactRepo.FindAll().Select(t => new SelectListItem
            {
                Value = t.ContactPersonId.ToString(),
                Text  = t.LastName + " " + t.FirstName
            });
            ehvm.Owner = ownerRepo.FindAll().Select(t => new SelectListItem
            {
                Value = t.OwnerId.ToString(),
                Text  = t.LastName + " " + t.FirstName
            });

            ehvm.Status = statusRepo.FindAll().Select(t => new SelectListItem
            {
                Value = t.St,
                Text  = t.St
            });

            return(View("Create", ehvm));
        }
Example #3
0
 public void AddHotel(Hotel hotel)
 {
     hotelRepository.AddHotel(hotel);
 }
 public bool AddHotel(HotelModel hotel)
 {
     return(HotelRepository.AddHotel(ModelMapperService.Map <HotelModel, Hotel>(hotel)));
 }
        public HotelViewModel AddHotel(HotelViewModel hvmodel)
        {
            var data = _hotelRepository.AddHotel(hvmodel);

            return(data);
        }
Example #6
0
        public ActionResult <string> Post([FromBody] string hotelname)
        {
            _hotelRepository.AddHotel(hotelname);

            return(Ok("Your hotel was created"));
        }
        public JsonResult AddHotel(HotelModel model)
        {
            string data = repository.AddHotel(model);

            return(Json(data, JsonRequestBehavior.AllowGet));
        }
Example #8
0
        public async Task <ActionResult <Hotel> > PostHotel(Hotel hotel)
        {
            await hotelRepository.AddHotel(hotel);

            return(CreatedAtAction("GetHotel", new { id = hotel.ID }, hotel));
        }
Example #9
0
 public Hotel AddHotel(Hotel hotel)
 {
     return(_hotelRepository.AddHotel(hotel));
 }