public async Task <DataResult> Delete(string id)
        {
            await _repository
            .Remove(Builders <Reservation> .Filter.Eq("_id", id));

            return(DataResultBuilder.Success());
        }
        public async Task <DataResult> EditRoom(string id, Room model)
        {
            await _repository.Edit(Builders <Room> .Filter.Eq("_id", id),
                                   Builders <Room> .Update
                                   .Set("number", model.Number)
                                   .Set("floor", model.Floor));

            return(DataResultBuilder.Success());
        }
Пример #3
0
 public async Task <DataResult <List <Client> > > SearchClients(string phrase)
 {
     return(DataResultBuilder.Success(await _repository.
                                      Search(Builders <Client> .Filter.Or(
                                                 Builders <Client> .Filter.Regex("_id", $".*{phrase}.*"),
                                                 Builders <Client> .Filter.Regex("location", $".*{phrase}.*"),
                                                 Builders <Client> .Filter.Regex("firstname", $".*{phrase}.*"),
                                                 Builders <Client> .Filter.Regex("lastname", $".*{phrase}.*")
                                                 ))));
 }
Пример #4
0
        public async Task <DataResult> EditClient(string id, Client model)
        {
            await _repository.Edit(Builders <Client> .Filter.Eq("_id", id),
                                   Builders <Client> .Update
                                   .Set("location", model.Location)
                                   .Set("firstname", model.Firstname)
                                   .Set("lastname", model.Lastname));

            return(DataResultBuilder.Success());
        }
        public async Task <DataResult> Edit(string id, Reservation model)
        {
            await _repository.Edit(Builders <Reservation> .Filter.Eq("_id", id),
                                   Builders <Reservation> .Update
                                   .Set("number", model.Number)
                                   .Set("from", model.From)
                                   .Set("to", model.To)
                                   .Set("room", model.Room));

            return(DataResultBuilder.Success());
        }
        public async Task <DataResult> Add(Reservation model)
        {
            var existsReservations = await _repository.Search(Builders <Reservation> .Filter.And(
                                                                  Builders <Reservation> .Filter.Eq("room.number", model.Room.Number),
                                                                  Builders <Reservation> .Filter.Or(Builders <Reservation> .Filter.Gte("from", model.From),
                                                                                                    Builders <Reservation> .Filter.Gte("to", model.To))
                                                                  ));

            if (existsReservations.Count > 0)
            {
                return(DataResultBuilder.Failed("W tym okresie ten pokój jest zajęty!"));
            }
            await _repository.InsertOne(model);

            return(DataResultBuilder.Success());
        }
 public async Task <DataResult <List <Reservation> > > GetAll()
 {
     return(DataResultBuilder.Success(await _repository.GetAll()));
 }
 public async Task <DataResult <Reservation> > Get(string id)
 {
     return(DataResultBuilder.Success(await _repository
                                      .GetByCondition(Builders <Reservation> .Filter.Eq("_id", id))));
 }
        public async Task <DataResult> DeleteRoom(string roomId)
        {
            await _repository.Remove(Builders <Room> .Filter.Eq("_id", roomId));

            return(DataResultBuilder.Success());
        }
        public async Task <DataResult> Add(Room model)
        {
            await _repository.InsertOne(model);

            return(DataResultBuilder.Success());
        }