コード例 #1
0
        private void buttonAdd_Click(object sender, EventArgs e)
        {
            if (ValidationService.ValidateHotelName(textBoxHotelName.Text) && ValidationService.ValidateFoundationYear(dateTimePickerFYear.Value))
            {
                var hotel = new Hotel()
                {
                    HotelName      = textBoxHotelName.Text,
                    Adress         = textBoxAdress.Text,
                    FoundationYear = dateTimePickerFYear.Value,
                    IsActive       = Convert.ToBoolean(comboBoxIsActive.Text),
                    Created        = DateTime.Now
                };

                using (var context = ContextResolver.GetContext(connectionString))
                {
                    var hotelService = new HotelService(context);
                    hotelService.Add(hotel);
                }
                MessageBox.Show("New record has been added");
                this.Close();
            }
            else
            {
                labelValidationMessage.Visible = true;
            }
        }
コード例 #2
0
        public ResultViewModels <HotelEditViewModel> AddHotel(HotelEditViewModel HotelEditView)
        {
            ResultViewModels <HotelEditViewModel> result
                = new ResultViewModels <HotelEditViewModel>();

            try
            {
                var hotelTemp = HotelService.Add(HotelEditView);
                if (hotelTemp == null)
                {
                    result.Successed = false;
                    result.Message   = "Data is empty";
                }
                else
                {
                    result.Successed = true;

                    result.Message = "Data added";
                    result.Data    = hotelTemp;
                }
            }
            catch (Exception ex)
            {
                result.Successed = false;
                result.Message   = "Something Went Wrong !!";
            }

            return(result);
        }
コード例 #3
0
        public ActionResult Create(hotel hotel)
        {
            hs.Add(hotel);
            hs.Commit();


            return(RedirectToAction("Index"));
        }
コード例 #4
0
        public async Task Add_WhenCalled_ShouldAddAHotel()
        {
            using (var context = new ApplicationContext(options))
            {
                var hotelService = new HotelService(context,
                                                    imageServiceMock.Object,
                                                    thumbnailServiceMock.Object,
                                                    localizerMock.Object,
                                                    mapper.Object);
                var contextLength = context.Hotels.Count();
                var hotelName     = "New Hotel";

                var hotel = await hotelService.Add(
                    new Hotel { Name = hotelName }
                    );

                Assert.Equal(contextLength + 1, context.Hotels.Count());
                Assert.True(context.Hotels.Contains(hotel));
                Assert.Equal(hotelName, context.Hotels.Find(hotel.HotelId).Name);
            }
        }
コード例 #5
0
ファイル: HotelController.cs プロジェクト: hosam00/luxorna
        public HotelEditViewModel AddHotel(HotelEditViewModel HotelEditView)
        {
            var Hotel = HotelService.Add(HotelEditView);

            return(Hotel);
        }