예제 #1
0
        public ActionResult Edit(int?id)
        {
            if (id.HasValue)
            {
                var ZH = _dbzh.CodeFile.Where(o => o.ItemType == "Bed" && o.ID == id).FirstOrDefault();

                if (ZH == null)
                {
                    return(View());
                }

                var EN = _dbus.CodeFile.Where(o => o.ItemType == "Bed" && o.ParentId == ZH.ID).FirstOrDefault();
                if (ZH == null)
                {
                    return(View());
                }

                var model = new BedViewModel();
                model.ID      = ZH.ID;
                model.NameZH  = ZH.ItemDescription;
                model.NameEN  = EN.ItemDescription;
                model.Deleted = ZH.Deleted;
                return(View(model));
            }
            return(View());
        }
예제 #2
0
        public List <BedViewModel> GetAllBedFromView()
        {
            Query   = "SELECT * FROM ViewAllBeds ORDER BY BedName";
            Command = new SqlCommand(Query, Connection);
            //Connection.Open();
            Reader = Command.ExecuteReader();
            List <BedViewModel> bedViewModels = new List <BedViewModel>();
            int sl = 0;

            while (Reader.Read())
            {
                sl++;
                BedViewModel aBedViewModel = new BedViewModel();
                aBedViewModel.Sl           = Convert.ToInt32(sl);
                aBedViewModel.Id           = Convert.ToInt32(Reader["BedId"]);
                aBedViewModel.BedName      = Reader["BedName"].ToString();
                aBedViewModel.Description  = Reader["BedDescription"].ToString();
                aBedViewModel.Rate         = Convert.ToInt32(Reader["Rate"]);
                aBedViewModel.FloorId      = Convert.ToInt32(Reader["FloorId"]);
                aBedViewModel.FloorName    = Reader["FloorName"].ToString();
                aBedViewModel.CategoryId   = Convert.ToInt32(Reader["CategoryId"]);
                aBedViewModel.CategoryName = Reader["CategoryName"].ToString();
                aBedViewModel.WardId       = Convert.ToInt32(Reader["WardId"]);
                aBedViewModel.WardName     = Reader["WardName"].ToString();
                aBedViewModel.RoomId       = Convert.ToInt32(Reader["RoomId"]);
                aBedViewModel.RoomName     = Reader["RoomName"].ToString();

                bedViewModels.Add(aBedViewModel);
            }
            Reader.Close();
            //Connection.Close();
            return(bedViewModels);
        }
        public async Task <IActionResult> AddBed(BedViewModel newBed, long hotelId, long roomId)
        {
            if (ModelState.IsValid)
            {
                await bedService.AddBedAsync(newBed, roomId);

                return(RedirectToAction(nameof(HotelController.HotelInfo), "Hotel", new { hotelId }));
            }
            return(View(newBed));
        }
예제 #4
0
        public ActionResult Edit(BedViewModel model)
        {
            model.Creator = CurrentUser.Id;
            if (model.ID > 0)
            {
                model.Edit();
                return(RedirectToAction("Index"));
            }
            else
            {
                model.Create();
                return(RedirectToAction("Index"));
            }

            //return View();
        }
        public async Task AddBed_WhenValid_ShouldCallServiceAndRedirect()
        {
            var controller   = new RoomsController(bedServiceMock.Object, roomServiceMock.Object, hotelServiceMock.Object);
            var hotelId      = 1;
            var bedViewModel = new BedViewModel();

            var result = await controller.AddBed(hotelId, bedViewModel);

            var redirectResult = Assert.IsType <RedirectToActionResult>(result);
            var resultHotelId  = (int)redirectResult.RouteValues["id"];

            Assert.Equal("Hotels", redirectResult.ControllerName);
            Assert.Equal(nameof(HotelsController.Hotel), redirectResult.ActionName);
            Assert.Equal(hotelId, resultHotelId);
            bedServiceMock.Verify(s => s.AddBed(bedViewModel), Times.Once);
        }
예제 #6
0
        /// <summary>
        ///  Maps to Bed View Model
        /// </summary>
        /// <param name="bedList"></param>
        /// <returns>List<BedViewModel></returns>
        public static BaseResult <List <BedViewModel> > MapBedList(BaseResult <List <Bed> > bedList)
        {
            BaseResult <List <BedViewModel> > bedViewModelList = new BaseResult <List <BedViewModel> >();
            List <BedViewModel> modelList = new List <BedViewModel>();

            foreach (var item in bedList.Result)
            {
                BedViewModel model = new BedViewModel
                {
                    Id   = item.Id,
                    Name = item.Name
                };
                modelList.Add(model);
            }
            bedViewModelList.Result = modelList;
            return(bedViewModelList);
        }
예제 #7
0
        private void AdmitButtonClickedEvent_Handler(object sender, RoutedEventArgs e)
        {
            e.Handled = true;
            BedViewModel bedViewModel = GetBedViewModel(e.Source);

            if (bedViewModel == null)
            {
                return;
            }
            //BedView bed = e.Source as BedView;
            //BedViewModel bedViewModel = bed.DataContext as BedViewModel;
            string bedId = bedViewModel.BedId;

            if (NavigationService != null)
            {
                NavigationService.Navigate(new AdmitPatientPage(bedId));
            }
        }
예제 #8
0
        private void UpdateVitalsButtonClickedEvent_Handler(object sender, RoutedEventArgs e)
        {
            e.Handled = true;
            //BedView bed = e.Source as BedView;
            //BedViewModel bedViewModel = bed.DataContext as BedViewModel;
            BedViewModel patientBedViewModel = GetBedViewModel(e.Source);

            if (patientBedViewModel == null)
            {
                return;
            }

            string bedId     = patientBedViewModel.BedId;
            string patientId = patientBedViewModel.PatientId;

            if (NavigationService != null)
            {
                NavigationService.Navigate(new UpdateVitalsPage(patientId, bedId));
            }
        }
예제 #9
0
        public async Task AddBedAsync(BedViewModel newBed, long roomId)
        {
            var room = await roomService.FindRoomByIdAsync(roomId);

            var bed = mapper.Map <BedViewModel, Bed>(newBed);
            await applicationContext.AddAsync(bed);

            await applicationContext.SaveChangesAsync();

            var roomBed = new RoomBed
            {
                Room   = room,
                RoomId = roomId,
                Bed    = bed,
                BedId  = bed.BedId
            };

            room.RoomBeds.Add(roomBed);

            await applicationContext.SaveChangesAsync();
        }
예제 #10
0
        public async Task <RoomBed> AddBed(BedViewModel model)
        {
            var roomBedFromContext = await applicationContext.RoomBeds
                                     .Where(r => r.BedId == model.BedId && r.RoomId == model.RoomId)
                                     .SingleOrDefaultAsync();

            var roomBed = new RoomBed
            {
                RoomId    = model.RoomId,
                BedId     = model.BedId,
                BedNumber = model.BedNumber
            };

            if (roomBedFromContext == null)
            {
                await applicationContext.AddAsync(roomBed);

                await applicationContext.SaveChangesAsync();
            }
            return(roomBed);
        }
예제 #11
0
        private void bedListView_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            BedViewModel aBedViewModel = bedListView.SelectedItems[0].Tag as BedViewModel;

            if (aBedViewModel != null)
            {
                //itemIdTextBox.Text = aItemViewModel.Id.ToString();
                bedIdTextBox.Text              = aBedViewModel.Id.ToString();
                bedNameTextBox.Text            = aBedViewModel.BedName;
                floorComboBox.SelectedValue    = aBedViewModel.FloorId;
                categoryComboBox.SelectedValue = aBedViewModel.CategoryId;
                wardComboBox.SelectedValue     = aBedViewModel.WardId;
                roomComboBox.SelectedValue     = aBedViewModel.RoomId;
                descriptionTextBox.Text        = aBedViewModel.Description;
                rateTextBox.Text = aBedViewModel.Rate.ToString();

                deleteButton.Enabled = true;
                saveButton.Text      = "Update";
            }
            deleteButton.Enabled = true;
        }
        public async Task <IActionResult> AddBed(int hotelId, BedViewModel model)
        {
            await bedService.AddBed(model);

            return(RedirectToAction(nameof(HotelsController.Hotel), "Hotels", new { id = hotelId }));
        }
예제 #13
0
 public BedView(BedDataModel bed)
 {
     InitializeComponent();
     DataContext = new BedViewModel(bed);
 }