public async Task <IActionResult> GetAll() { var parentModels = await _parentRepositoryManager.GetAll() .Include(parentModel => parentModel.ChildModels) .ToListAsync(); return(Ok(parentModels)); }
public async Task <IEnumerable <IngridientDto> > GetIngridientsAsync(string userId) { var ingridientDtos = new List <IngridientDto>(); var ingridients = await _repositoryIngridient .GetAll() .AsNoTracking() .Where(ingridient => ingridient.UserId == userId) .ToListAsync(); if (!ingridients.Any()) { return(ingridientDtos); } foreach (var ingridient in ingridients) { ingridientDtos.Add(new IngridientDto { Id = ingridient.Id, Name = ingridient.Name, Category = ingridient.Category, IsVeggie = ingridient.IsVeggie, Description = ingridient.Description, Colories = ingridient.Colories, IsRecomended = ingridient.IsRecomended, ReactionType = ingridient.ReactionType, Date = ingridient.Date }); } return(ingridientDtos); }
public async Task <IEnumerable <ReadyMealDto> > GetReadyMealsAsync(string userId) { var readyMealDtos = new List <ReadyMealDto>(); var readymeals = await _repositoryReadyMeal .GetAll() .AsNoTracking() .Where(readymeal => readymeal.UserId == userId) .ToListAsync(); if (!readymeals.Any()) { return(readyMealDtos); } foreach (var readymeal in readymeals) { readyMealDtos.Add(new ReadyMealDto { Id = readymeal.Id, Name = readymeal.Name, ChildReacrion = readymeal.ChildReacrion, TeastyMeal = readymeal.TeastyMeal, Comment = readymeal.Comment, ReadyTime = readymeal.ReadyTime, Picture = readymeal.Picture, }); } return(readyMealDtos); }
public List <RideDetails> SearchAvailableRides(RequestBooking rideBooking, long userId) { List <RideDetails> Rides = new List <RideDetails>(); List <OfferRide> TotalRides = _rideOffersRepository.GetAll().ToList(); TotalRides.ForEach(e => e.Route = _placeRepository.GetAll().Where(r => r.RideOfferId == e.RideOfferId).ToList()); List <OfferRide> AvailableRides = TotalRides .Where(r => r.Route.Exists(e => e.AreaName == rideBooking.StartPoint) && r.Route.Exists(e => e.AreaName == rideBooking.Destination) && r.HostId != userId && ( r.Route.FindIndex(e => e.AreaName == rideBooking.StartPoint) < r.Route.FindIndex(e => e.AreaName == rideBooking.Destination)) && r.Time == rideBooking.Time && r.AvailableSeats >= rideBooking.Seats && (DateTime.Compare(r.RideOfferedDate, rideBooking.RideBookingDate) == 0)) .ToList(); foreach (OfferRide ride in AvailableRides) { string[] Startpoint = ride.Route[0].AreaName.Split(','); string[] Destination = ride.Route[ride.Route.Count - 1].AreaName.Split(','); RideDetails rideDetails = _mapper.Map <OfferRide, RideDetails>(ride); rideDetails.Name = _userRepository.Get(ride.HostId).Name; rideDetails.StartPoint = Startpoint[0]; rideDetails.Destination = Destination[0]; rideDetails.RideBookingDate = ride.RideOfferedDate.ToString("dd/MM/yyyy"); rideDetails.RideFair = GetPrice(rideBooking.StartPoint, rideBooking.Destination); rideDetails.Seats = ride.AvailableSeats; Rides.Add(rideDetails); } return(Rides); }
public async Task <IEnumerable <ProfileDto> > GetProfileAsync(string userId) { var profiles = await _repositoryProfile .GetAll() .AsNoTracking() .Where(profiles => profiles.UserId == userId) .ToListAsync(); var profilesDtos = new List <ProfileDto>(); foreach (var profile in profiles) { profilesDtos.Add(new ProfileDto { Id = profile.Id, UserId = profile.UserId, FirstName = profile.FirstName, LastName = profile.LastName, MiddleName = profile.MiddleName, BirthDate = profile.BirthDate, Phone = profile.Phone, Telegram = profile.Telegram, SocialNetwork = profile.SocialNetwork, ProfilePicture = profile.ProfilePicture, }); } return(profilesDtos); }
public List <RideDetails> GetAllBookings(long userId) { List <Booking> UserBookings = _repository.GetAll().Where(r => r.BookingUserId == userId && r.Status != BookingStatus.Requested).ToList(); List <RideDetails> UserRideBookings = new List <RideDetails>(); foreach (Booking userBooking in UserBookings) { RideDetails rideDetails = _mapper.Map <Booking, RideDetails>(userBooking); rideDetails.Name = _userRepository.Get(_rideOffersRepository.Get(_repository.GetAll().FirstOrDefault(r => r.Id == userBooking.Id).RideOfferId).HostId).Name; rideDetails.StartPoint = userBooking.StartPoint.Split(",")[0]; rideDetails.Destination = userBooking.Destination.Split(",")[0]; rideDetails.RideBookingDate = userBooking.RideBookingDate.ToString("dd/MM/yyyy"); UserRideBookings.Add(rideDetails); } return(UserRideBookings); }
public List <RideDetails> GetAllRidesOffered(long userId) { List <OfferRide> RideOffers = _repository.GetAll().Where(r => r.HostId == userId).ToList(); List <RideDetails> UserRideBookings = new List <RideDetails>(); foreach (OfferRide ride in RideOffers) { foreach (Booking rideBooking in _bookingRepository.GetAll().Where(r => r.RideOfferId == ride.RideOfferId)) { RideDetails rideDetails = _mapper.Map <Booking, RideDetails>(rideBooking); rideDetails.Name = _userRepository.Get(rideBooking.BookingUserId).Name; rideDetails.StartPoint = rideBooking.StartPoint.Split(",")[0]; rideDetails.Destination = rideBooking.Destination.Split(",")[0]; rideDetails.RideBookingDate = rideBooking.RideBookingDate.ToString("dd/MM/yyyy"); UserRideBookings.Add(rideDetails); } } return(UserRideBookings); }
public async Task <IEnumerable <ProductDetailDto> > GetAllProductDetailsAsync() { var productDetails = await _productDetailRepository .GetAll() .Where(productDetail => productDetail.Products.Any(p => !p.IsArchived)) .ToListAsync(); IEnumerable <ProductDetailDto> GetProductDetails() { foreach (var productDetail in productDetails) { yield return(new ProductDetailDto { Id = productDetail.Id, Name = productDetail.Name, Description = productDetail.Description, Comment = productDetail.Comment, }); } } return(GetProductDetails()); }
public bool CheckIsUnique(string username) { return(_repository.GetAll().FirstOrDefault(a => a.Username == username) != null ? true : false); }
public long CheckIfOwnsCar(long id) { return(_repository.GetAll().ToList().Exists(e => e.CarOwnerId == id)? _repository.GetAll().ToList().First(e => e.CarOwnerId == id).CarId:0); }
public async Task <IEnumerable <RepositoryEntity> > GetAll() { return(await _manager.GetAll()); }