public AddAnimalViewModel(SearchAnimalViewModel parent)
 {
     prnt   = parent;
     Image  = new ImageModel();
     Animal = new AnimalModel();
     Stay   = new StayModel();
 }
        public async Task <IActionResult> Put(StayModel stay)
        {
            _unitOfWork.Stay.Update(stay);
            await _unitOfWork.CommitAsync();

            return(Accepted(stay));
        }
        public void Test_Create_StayModel(StayModel stay)
        {
            var validationContext = new ValidationContext(stay);
            var actual            = Validator.TryValidateObject(stay, validationContext, null, true);

            Assert.True(actual);
        }
 public AddAnimalViewModel(HomeViewModel parent)
 {
     prnt1  = parent;
     Image  = new ImageModel();
     Animal = new AnimalModel();
     Stay   = new StayModel();
 }
示例#5
0
 public void ClearNewStay()
 {
     NewStay = new StayModel();
     NotifyOfPropertyChange(() => NewStayDate);
     NotifyOfPropertyChange(() => NewFindDate);
     NotifyOfPropertyChange(() => NewFindPlace);
 }
        public async Task <IActionResult> Post(StayModel stay)
        {
            await _unitOfWork.Stay.InsertAsync(stay);

            await _unitOfWork.CommitAsync();

            return(Accepted(stay));
        }
示例#7
0
        public async void Test_Repository_Update(BookingModel booking, StayModel stay)
        {
            await _connection.OpenAsync();

            try
            {
                using (var ctx = new BookingContext(_options))
                {
                    await ctx.Database.EnsureCreatedAsync();

                    await ctx.Bookings.AddAsync(booking);

                    await ctx.Stays.AddAsync(stay);

                    await ctx.SaveChangesAsync();
                }

                using (var ctx = new BookingContext(_options))
                {
                    var rentals = new List <RentalModel>();
                    var rental  = new RentalModel {
                        Id = 1
                    };
                    rentals.Add(rental);
                    booking.Rentals = rentals;
                    var bookings = new Repository <BookingModel>(ctx);
                    var expected = await ctx.Bookings.FirstAsync();

                    expected.Status = "updated";
                    bookings.Update(expected);
                    await ctx.SaveChangesAsync();

                    var actual = await ctx.Bookings.FirstAsync();

                    Assert.Equal(expected, actual);
                }


                using (var ctx = new BookingContext(_options))
                {
                    var stays    = new Repository <StayModel>(ctx);
                    var expected = await ctx.Stays.FirstAsync();

                    expected.DateModified = DateTime.Now;
                    stays.Update(expected);
                    await ctx.SaveChangesAsync();

                    var actual = await ctx.Stays.FirstAsync();

                    Assert.Equal(expected, actual);
                }
            }
            finally
            {
                _connection.Close();
            }
        }
示例#8
0
        private async Task FilterData()
        {
            IsWorking = true;
            await Task.Delay(150);

            await Task.Run(() =>
            {
                AnimalStays = StayModel.GetDatedStays(Since, To);
            });

            IsWorking = false;
        }
示例#9
0
        private async Task LoadData()
        {
            IsWorking = true;
            await Task.Delay(150);

            await Task.Run(() =>
            {
                AnimalStays = StayModel.GetAnimalStays(AnimalID);
            });

            IsWorking = false;
        }
        private async Task LoadData()
        {
            IsWorking = true;
            await Task.Delay(150);

            await Task.Run(() =>
            {
                Stays = StayModel.GetDatedStays(DateTime.Now.AddYears(-100), DateTime.Now.AddYears(100));
            });

            IsWorking = false;
        }
示例#11
0
        public async void Test_Repository_SelectAsync(BookingModel booking, StayModel stay)
        {
            await _connection.OpenAsync();

            try
            {
                using (var ctx = new BookingContext(_options))
                {
                    await ctx.Database.EnsureCreatedAsync();

                    await ctx.Bookings.AddAsync(booking);

                    await ctx.Stays.AddAsync(stay);

                    await ctx.SaveChangesAsync();
                }

                using (var ctx = new BookingContext(_options))
                {
                    var bookings = new Repository <BookingModel>(ctx);

                    var actual = await bookings.SelectAsync();

                    Assert.NotEmpty(actual);
                }

                using (var ctx = new BookingContext(_options))
                {
                    var bookings = new BookingRepository(ctx);

                    var actual = await bookings.SelectAsync();

                    Assert.NotEmpty(actual);
                }

                using (var ctx = new BookingContext(_options))
                {
                    var stays = new StayRepository(ctx);

                    var actual = await stays.SelectAsync();

                    Assert.NotEmpty(actual);
                }
            }
            finally
            {
                _connection.Close();
            }
        }
 public void FilterStays()
 {
     if (StaySince == null || StayTo == null)
     {
         IsWorking = true;
         Stays     = StayModel.GetDatedStays(DateTime.Now.AddYears(-100), DateTime.Now.AddYears(100));
         IsWorking = false;
     }
     else
     {
         IsWorking = true;
         Stays     = StayModel.GetDatedStays(StaySince, StayTo);
         IsWorking = false;
     }
 }
        public void DeleteStay()
        {
            MessageBoxResult result = MessageBox.Show("Opravdu chcete vymazat zvolený pobyt?",
                                                      "Confirmation",
                                                      MessageBoxButton.YesNo,
                                                      MessageBoxImage.Question);

            if (result == MessageBoxResult.Yes)
            {
                StayModel.MarkAsDeleted((int)SelectedStay.ID);

                SelectedStay = null;

                FilterStays();
            }
        }
示例#14
0
        public async Task <IActionResult> Post(StayModel stay)
        {
            if (ModelState.IsValid)
            {
                await _unitOfWork.Stay.InsertAsync(stay);

                await _unitOfWork.CommitAsync();

                return(Accepted(stay));
            }
            else
            {
                // Model state is invalid.
                return(BadRequest());
            }
        }
示例#15
0
        public async void Restore()
        {
            if (Since == null || To == null || (Since > To))
            {
                MessageBox.Show("Zvolte prosím platné datum.");
            }
            else
            {
                IsWorking = true;
                await Task.Delay(150);

                await Task.Run(() =>
                {
                    AdoptionModel.RestoreDeleted((DateTime)Since, (DateTime)To);
                    AnimalModel.RestoreDeleted((DateTime)Since, (DateTime)To);
                    BreedModel.RestoreDeleted((DateTime)Since, (DateTime)To);
                    CoatTypeModel.RestoreDeleted((DateTime)Since, (DateTime)To);
                    CostModel.RestoreDeleted((DateTime)Since, (DateTime)To);
                    DeathModel.RestoreDeleted((DateTime)Since, (DateTime)To);
                    DiaryModel.RestoreDeleted((DateTime)Since, (DateTime)To);
                    DonationModel.RestoreDeleted((DateTime)Since, (DateTime)To);
                    EscapeModel.RestoreDeleted((DateTime)Since, (DateTime)To);
                    FurColorModel.RestoreDeleted((DateTime)Since, (DateTime)To);
                    IncidentModel.RestoreDeleted((DateTime)Since, (DateTime)To);
                    PersonModel.RestoreDeleted((DateTime)Since, (DateTime)To);
                    MedicalRecordModel.RestoreDeleted((DateTime)Since, (DateTime)To);
                    SpeciesModel.RestoreDeleted((DateTime)Since, (DateTime)To);
                    StayModel.RestoreDeleted((DateTime)Since, (DateTime)To);
                    WalkModel.RestoreDeleted((DateTime)Since, (DateTime)To);
                });

                ComboBoxSettings();
                IsWorking = false;
                MessageBox.Show("Záznamy od " + Since + " do " + To + " obnoveny.");
            }
        }
示例#16
0
        public async void Test_Count(BookingModel booking, StayModel stay)
        {
            await _connection.OpenAsync();

            try
            {
                using (var ctx = new BookingContext(_options))
                {
                    await ctx.Database.EnsureCreatedAsync();

                    await ctx.Bookings.AddAsync(booking);

                    await ctx.Stays.AddAsync(stay);

                    await ctx.SaveChangesAsync();
                }
                using (var ctx = new BookingContext(_options))
                {
                    var bookings     = new Repository <BookingModel>(ctx);
                    var bookingCount = bookings.Count();

                    Assert.Equal(1, bookingCount);
                }

                using (var ctx = new BookingContext(_options))
                {
                    var stays     = new Repository <StayModel>(ctx);
                    var stayCount = stays.Count();
                    Assert.Equal(1, stayCount);
                }
            }
            finally
            {
                _connection.Close();
            }
        }
示例#17
0
        public void Test_Validate_StayModel(StayModel stay)
        {
            var validationContext = new ValidationContext(stay);

            Assert.Empty(stay.Validate(validationContext));
        }
        public async void Test_Repository_selectAsync_ByFilter(BookingModel booking, StayModel stay)
        {
            await _connection.OpenAsync();

            try
            {
                using (var ctx = new BookingContext(_options))
                {
                    await ctx.Database.EnsureCreatedAsync();

                    await ctx.Bookings.AddAsync(booking);

                    await ctx.Stays.AddAsync(stay);

                    await ctx.SaveChangesAsync();
                }

                using (var ctx = new BookingContext(_options))
                {
                    var bookings = new Repository <BookingModel>(ctx);

                    var actual = await bookings.SelectAsync(null, null, "", 0, 50);

                    Assert.NotEmpty(actual);

                    actual = await bookings.SelectAsync(null, null, "", 0, 50);

                    Assert.NotEmpty(actual);
                }

                using (var ctx = new BookingContext(_options))
                {
                    var stays = new Repository <StayModel>(ctx);

                    var actual = await stays.SelectAsync(null, null, "", 0, 50);

                    Assert.NotEmpty(actual);
                }

                using (var ctx = new BookingContext(_options))
                {
                    var stays = new Repository <StayModel>(ctx);
                    List <Expression <Func <StayModel, bool> > > _filters = new List <Expression <Func <StayModel, bool> > >();
                    _filters.Add(s => s.Id > 0);

                    SearchFilter <StayModel> searchFilter = new SearchFilter <StayModel>
                    {
                        Includes = "Booking",
                        Filters  = _filters,
                        OrderBy  = stays => stays.OrderBy(stay => stay.Id),
                    };
                    var actual = await stays.SelectAsync(searchFilter);

                    Assert.NotNull(actual);
                }
            }
            finally
            {
                _connection.Close();
            }
        }
示例#19
0
 public StaysViewModel(int animalID)
 {
     AnimalID = animalID;
     Stay     = new StayModel();
     NewStay  = new StayModel();
 }