示例#1
0
        public IDataResult <List <CarDetailDto> > GetCarById(int id)
        {
            var          result      = new SuccessDataResult <List <CarDetailDto> >(_iCarDal.GetCarById(id), Messages.CarById);
            ICarImageDal carImageDal = new EfCarImageDal();

            //ICarImageService carimagemanager = new CarImageManager(carImageDal);
            //List<CarImage> carimages = carimagemanager.GetImagesByCarId(id);
            //result.Data.CarImages = carimages;
            return(result);
        }
示例#2
0
        public IDataResult <CustomerFindex> GetFindexByCustomerId(int customerId)
        {
            var result = new SuccessDataResult <CustomerFindex>(findexDal.Get(x => x.CustomerId == customerId));

            if (result.Data != null)
            {
                return(result);
            }
            return(new ErrorDataResult <CustomerFindex>(findexDal.Get(x => x.CustomerId == customerId)));
        }
示例#3
0
        private IResult CheckReturnDate(int carId, DateTime?returnDate)
        {
            var result = new SuccessDataResult <Rental>(_rentalDal.Get(r => r.CarId == carId)).Data;

            if (result != null)
            {
                return(new ErrorResult(Messages.CantRent));
            }
            return(new SuccessResult(Messages.RentAdded));
        }
示例#4
0
        public async Task <IDataResult <CarImage> > GetCarImageById(int carImageId)
        {
            //TODO CheckIfCarImageExists
            var dataResult = new SuccessDataResult <CarImage>(_carImageDal.Get(image => image.Id == carImageId));



            await FileHelper.WriteImageBytesToImagesGet(dataResult.Data.ImagePath, dataResult.Data.ImageName);

            return(dataResult);
        }
示例#5
0
        public IDataResult <List <Car> > GetCarsByDailyPrice(decimal min, decimal max)
        {
            var result = new SuccessDataResult <List <Car> >(_carDal.GetAll(c => c.DailyPrice >= min && c.DailyPrice <= max));

            if (result.Data.Count == 0)
            {
                return(new ErrorDataResult <List <Car> >(Messages.CarListingFailed));
            }

            return(new SuccessDataResult <List <Car> >(_carDal.GetAll(c => c.DailyPrice >= min && c.DailyPrice <= max)));
        }
示例#6
0
        public IDataResult <List <RentalDto> > GetRentalsDto(int carId)
        {
            var result = new SuccessDataResult <List <RentalDto> >(rentalDal.GetRentalsDto(carId));

            if (result.Data.Count > 0)
            {
                if (DateTime.Compare(result.Data[0].ReturnDate, DateTime.Now) > 0 || DateTime.Compare(result.Data[0].ReturnDate, DateTime.Now) == 0)
                {
                    return(new ErrorDataResult <List <RentalDto> >("Araç " + result.Data[0].ReturnDate.ToShortDateString() + " tarihine kadar  başka bir üyemize kiralanmıştır."));
                }
            }
            return(new SuccessDataResult <List <RentalDto> >(result.Data, Messages.avaible));
        }
        public IResult Update(Rental rental)
        {
            var result = new SuccessDataResult <List <Rental> >(_rentalDal.GetAll(r => r.CarId == rental.CarId)).Data;

            if (result.Count > 0 && result.Count(r => r.ReturnDate == null) > 0)
            {
                return(new ErrorReslut(Messages.RentalAddedError));
            }
            else
            {
                _rentalDal.Update(rental);
                return(new SuccessResult(Messages.RentalAdded));
            }
        }
示例#8
0
        public IDataResult <CreditCard> GetCardByNumber(string card)
        {
            bool dene = ValidationRules.ValidationOthers.ValidCard(card);

            if (dene)
            {
                var result = new SuccessDataResult <CreditCard>(creditDal.Get(x => x.CardNumber == card));
                if (result.Data != null)
                {
                    return(result);
                }
                return(new SuccessDataResult <CreditCard>("Kart numarası kredi kartları merkezinde kayıtlı değil"));
            }
            return(new ErrorDataResult <CreditCard>("Kart numarası geçerli bir numara değil "));
        }
        public async Task <DataResult <GetAdminDto> > InsertAsync(InsertAdminDto insertAdminDto)
        {
            var randomPass = RandomHelper.Mixed(6);

            HashingHelper.CreatePasswordHash(randomPass, out var passwordHash, out var passwordSalt);

            var admin = new Admin
            {
                Email    = insertAdminDto.Email,
                IsActive = true,
                Person   = new Person
                {
                    FirstName       = insertAdminDto.FirstName,
                    LastName        = insertAdminDto.LastName,
                    UserName        = insertAdminDto.Email,
                    Gsm             = insertAdminDto.Gsm,
                    PersonType      = PersonType.Admin,
                    CreatedUserName = "",
                    CreatedAt       = DateTime.Now,
                    PasswordHash    = passwordHash,
                    PasswordSalt    = passwordSalt,
                    RefreshToken    = RandomHelper.Mixed(32)
                }
            };

            await _repository.InsertAsync(admin);

            await _smsHelper.SendAsync(new List <string> {
                admin.Person.Gsm
            },
                                       "Welcome to the PatientTracker System. \n You are registered to patientTracker.net as Admin by " + _userService.FullName + " \n Your password is " + randomPass + "\n Wis");

            var result = await _repository.TableNoTracking.Where(x => x.Id == admin.Id)
                         .Include(x => x.Person)
                         .FirstOrDefaultAsync();

            var res = new SuccessDataResult <GetAdminDto>(new GetAdminDto
            {
                PersonId  = result.PersonId,
                UserName  = result.Person.UserName,
                FirstName = result.Person.FirstName,
                LastName  = result.Person.LastName,
                Gsm       = result.Person.Gsm,
                IsActive  = admin.IsActive
            });

            return(res);
        }
示例#10
0
        public async Task <IDataResult <User> > GetUser(int userID)
        {
            var user = await _cacheManager.Get <User>("GetUser?userID=" + userID.ToString());

            if (user != null)
            {
                return(new SuccessDataResult <User>(user));
            }
            else
            {
                var response = new SuccessDataResult <User>(await _userDal.GetUserWithIncludes(userID));
                await _cacheManager.Add("GetUserList", response.Data, 10000);

                return(response);
            }
        }
示例#11
0
        public async Task <IDataResult <List <User> > > GetUserList()
        {
            var users = await _cacheManager.Get <List <User> >("GetUserList");

            if (users != null)
            {
                return(new SuccessDataResult <List <User> >(users));
            }
            else
            {
                var response = new SuccessDataResult <List <User> >(await _userDal.GetUsersWithIncludes());
                await _cacheManager.Add("GetUserList", response.Data, 10000);

                return(response);
            }
        }
示例#12
0
        public IDataResult <List <CarImage> > GetCarImageById(int CarId)
        {
            var result = new SuccessDataResult <List <CarImage> >(imageService.GetAll(x => x.CarId == CarId));

            if (result.Data.Count != 0)
            {
                return(result);
            }
            for (int i = 0; i < 5; i++)
            {
                result.Data.Add(new CarImage {
                    Id = 0, CarId = CarId, ImagePath = "https://i.ytimg.com/vi/n_d5G1HF-_U/maxresdefault.jpg", Date = DateTime.Now
                });
            }
            return(result);
        }
示例#13
0
        public IResult Add(Rental rental)
        {
            var result = new SuccessDataResult <Rental>(_rentalDal.Get(r => r.CarId == rental.CarId)).Data;

            if (result != null)
            {
                if (result.ReturnDate == null || result.ReturnDate > DateTime.Now)
                {
                    return(new ErrorResult(Messages.CantRent));
                }
            }
            else
            {
                _rentalDal.Add(rental);
            }

            return(new SuccessResult(Messages.RentAdded));
        }
示例#14
0
        public IDataResult <List <Category> > GetAll()
        {
            var result = new SuccessDataResult <List <Category> >(_categoryDal.GetAll());

            return(result);
        }
示例#15
0
        public IDataResult <List <Car> > GetCarsByColorId(int ColorId)
        {
            SuccessDataResult <List <Car> > a = new SuccessDataResult <List <Car> >(_carDal.GetAll(c => c.ColorId == ColorId));

            return(a);
        }
示例#16
0
        public IDataResult <List <Car> > GetAllCarsIfNotRented()
        {
            var result = new SuccessDataResult <List <Car> >(_carDal.GetAll(c => !c.Rentals.Any(r => r.ReturnDate == null)));

            return(result);
        }
示例#17
0
        public IDataResult <List <Rental> > GetAll()
        {
            var a = new SuccessDataResult <List <Rental> >(_rentalDal.GetAll(), SuccessMessage.RentalListed);

            return(a);
        }
示例#18
0
        public IDataResult <List <CarRentalDetailDto> > GetRentalDetails()
        {
            var result = new SuccessDataResult <List <CarRentalDetailDto> >(_rentalDal.GetCarRentalDetails());

            return(result);
        }
示例#19
0
        public async Task <IDataResult <List <User> > > GetUserList()
        {
            var response = new SuccessDataResult <List <User> >(await _userDal.GetListAsync());

            return(response);
        }
示例#20
0
        public IDataResult <List <CarImage> > GetListByCarId(int id)
        {
            var Result = new SuccessDataResult <List <CarImage> >(_carImageDal.GetAll().Where(c => c.CarId == id).ToList());

            return(Result);
        }
示例#21
0
        public async Task <DataResult <GetDoctorDto> > InsertAsync(InsertDoctorDto insertDoctorDto)
        {
            var randomPass = RandomHelper.Mixed(6);

            HashingHelper.CreatePasswordHash(randomPass, out var passwordHash, out var passwordSalt);

            var doctor = new Doctor
            {
                Email        = insertDoctorDto.Email,
                IsActive     = true,
                DepartmentId = insertDoctorDto.DepartmentId,
                DegreeId     = insertDoctorDto.DegreeId,
                Person       = new Person
                {
                    FirstName               = insertDoctorDto.FirstName,
                    LastName                = insertDoctorDto.LastName,
                    Gsm                     = insertDoctorDto.Gsm,
                    CreatedAt               = DateTime.Now,
                    CreatedUserName         = _userService.FullName,
                    PersonType              = PersonType.Doctor,
                    UserName                = insertDoctorDto.Email,
                    PasswordHash            = passwordHash,
                    PasswordSalt            = passwordSalt,
                    RefreshToken            = RandomHelper.Mixed(32),
                    RefreshTokenExpiredDate = DateTime.Now.AddDays(-1)
                }
            };

            await _doctorRepo.InsertAsync(doctor);

            var hospital = await _doctorRepo.TableNoTracking
                           .Include(x => x.Department)
                           .Where(x => x.PersonId == doctor.PersonId)
                           .Select(x => x.Department.Hospital.Description)
                           .FirstOrDefaultAsync();


            await _smsHelper.SendAsync(new List <string> {
                doctor.Person.Gsm
            },
                                       "Welcome to the " + hospital + " \n You are registered to patracker as Doctor by " + _userService.FullName + " \n Your password is " + randomPass);


            var result = await _doctorRepo.TableNoTracking.Where(x => x.PersonId == doctor.PersonId)
                         .Include(x => x.Person)
                         .Include(x => x.Department)
                         .Include(x => x.Degree)
                         .FirstOrDefaultAsync();

            var res = new SuccessDataResult <GetDoctorDto>(new GetDoctorDto
            {
                Id             = result.Id,
                Email          = result.Email,
                FirstName      = result.Person.FirstName,
                LastName       = result.Person.LastName,
                Gsm            = result.Person.Gsm,
                DepartmentName = result.Department.Description,
                DegreeName     = result.Degree.Description
            });

            return(res);
        }