public bool ConfirmRentingDates(CarProfileModel car, DateTime to, DateTime from, ref string errorMessage) { for (var rentingDate = from; rentingDate <= to; rentingDate = rentingDate.AddDays(1)) { bool rent = false; foreach (var date in car.DayThatIsRented) { if (date.Date.Date == rentingDate.Date) { errorMessage = "*Another lessor has rented this car in the specified period"; return(false); } } foreach (var date in car.PossibleToRentDays) { if (date.Date.Date == rentingDate.Date) { rent = true; } } if (!rent) { errorMessage = "*It is not possible to rent the car in the specified period"; return(false); } } return(true); }
public async Task DeleteCarProfileTask(CarProfileModel CarProfile) { using (var db = _dbContextFactory.GetContext()) { await db.RemoveCarProfile(CarProfile.RegNr); } }
public MessageFromLessorModel(UserModel renter, UserModel lessor, CarProfileModel rentCar, string message, MsgStatus confirmationStatus) { Renter = renter; Lessor = lessor; RentCar = rentCar; Message = message; ConfirmationStatus = confirmationStatus; }
public async Task UpdateCarProfileTask(CarProfileModel carProfile) { using (var db = _dbContextFactory.GetContext()) { var dbCarProfile = _appToDbModelConverter.Convert(carProfile); await db.UpdateCarProfile(dbCarProfile); } }
public MessageFromRenterModel(UserModel renter, UserModel lessor, CarProfileModel rentCar, string message) { MsgType = MessageType.RenterMessage; Renter = renter; Lessor = lessor; RentCar = rentCar; Message = message; }
public ShowCarsListItemViewModel(IApplication application, CarProfileModel carProfile) { _application = application; _carProfile = carProfile; _carProfile.Model = "Test"; _carProfile.Brand = "Tester"; _carProfile.StartLeaseTime = DateTime.Today; _carProfile.EndLeaseTime = DateTime.Today; }
public async Task <List <DayThatIsRentedModel> > GetDaysThatIsRentedTask(CarProfileModel carProfile) { using (var db = _dbContextFactory.GetContext()) { var dbRentedDays = await db.GetCarProfileRentedDaysTask(carProfile.RegNr); var rentedDays = _dbToAppModelConverter.Convert(dbRentedDays); return(rentedDays); } }
public async Task <List <PossibleToRentDayModel> > GetPossibleToRentDayTask(CarProfileModel carProfile) { using (var db = _dbContextFactory.GetContext()) { var dbPossibleToRentDays = await db.GetCarProfilePossibleToRentDayTask(carProfile.RegNr); var possibleToRentDay = _dbToAppModelConverter.Convert(dbPossibleToRentDays); return(possibleToRentDay); } }
public async Task <List <MessageModel> > GetUserMessagesTask(UserModel user, int amount) { await Task.Delay(2000); var User1 = new UserModel("TestGetUserMessages1", "TestGetUserMessages1", "*****@*****.**", "TestGetUserMessages1", UserType.Lessor); var User2 = new UserModel("TestGetUserMessages2", "TestGetUserMessages2", "*****@*****.**", "TestGetUserMessages2", UserType.OrdinaryUser); var Car = new CarProfileModel(User2, "X-360", "BMW", 1989, "1234567", "Aarhus", 2, DateTime.Today, DateTime.Today, 1); //Find user messages user.MessageModels.Add(new MessageFromRenterModel(User2, User1, Car, "Må jeg godt låne din flotte bil?")); return(user.MessageModels); }
public async Task <List <CarProfileModel> > GetCarProfilesTask(UserModel user) { await Task.Delay(2000); var User1 = new UserModel("asd", "asd", "*****@*****.**", "asd", UserType.Lessor); var User2 = new UserModel("Marcus", "Gasberg", "*****@*****.**", "Gellerup", UserType.OrdinaryUser); var Car = new CarProfileModel(User2, "X-360", "BMW", 1989, "1234567", "Aarhus", 2, DateTime.Today, DateTime.Today, 1); return(new List <CarProfileModel>() { Car }); }
public async Task AddMessageToLessor(string mes, CarProfileModel carProfile, UserModel renter) { using (var db = _dbContextFactory.GetContext()) { var message = new MessageFromRenterModel(renter, carProfile.Owner, carProfile, mes) { Sender = renter, Receiver = carProfile.Owner, TimeStamp = DateTime.Now }; var dbMessage = _appToDbModelConverter.Convert(message); await db.AddMessage(dbMessage); } }
public async Task <UserModel> GetUserTask(UserModel user) { await Task.Delay(2000); var User1 = new UserModel("asd", "asd", "*****@*****.**", "asd", UserType.Lessor); var User2 = new UserModel("Marcus", "Gasberg", "*****@*****.**", "Gellerup", UserType.OrdinaryUser); var Car = new CarProfileModel(User2, "X-360", "BMW", 1989, "1234567", "Aarhus", 2, DateTime.Today, DateTime.Today, 1); return(new UserModel("Test", "Test", "*****@*****.**", "TestAddress", UserType.OrdinaryUser) { MessageModels = new List <MessageModel>() { new MessageFromLessorModel(User2, User1, Car, "Du kommer bare :)", MsgStatus.Confirmed), new MessageFromLessorModel(User2, User1, Car, "Det kan du godt glemme makker! Det kan du godt glemme makker! Det kan du godt glemme makker!", MsgStatus.Declined), new MessageFromRenterModel(User2, User1, Car, "Må jeg godt låne din flotte bil?"), } }); }
public async Task RegisterCarProfileTask(CarProfileModel CarProfile) { var possibleToRentDays = new List <PossibleToRentDayModel>(); for (var i = CarProfile.StartLeaseTime; i < CarProfile.EndLeaseTime; i += TimeSpan.FromDays(1)) { possibleToRentDays.Add(new PossibleToRentDayModel() { CarProfile = CarProfile, Date = i, }); } var carModel = _appToDbModelConverter.Convert(CarProfile); carModel.PossibleToRentDays = _appToDbModelConverter.Convert(possibleToRentDays); using (var db = _dbContextFactory.GetContext()) { await db.AddCarProfile(carModel); } }
public Task AddMessageToLessor(string mes, CarProfileModel carProfile, UserModel renter) { throw new NotImplementedException(); }
public List <DayThatIsRentedModel> CreateDayThatIsRentedList(DateTime from, DateTime to, CarProfileModel carProfile, UserModel renter) { var list = new List <DayThatIsRentedModel>(); for (var rentingDate = from; rentingDate.Date <= to.Date; rentingDate = rentingDate.AddDays(1)) { list.Add(new DayThatIsRentedModel() { CarProfileModel = carProfile, Date = rentingDate, Renter = renter }); } return(list); }
public async Task RegisterCarProfileTask(CarProfileModel CarProfile) { await Task.Delay(2000); }
public async Task DeleteCarProfileTask(CarProfileModel CarProfile) { await Task.Delay(2000); }
public Task <List <PossibleToRentDayModel> > GetPossibleToRentDayTask(CarProfileModel carProfile) { throw new NotImplementedException(); }
public Task <List <DayThatIsRentedModel> > GetDaysThatIsRentedTask(CarProfileModel carProfile) { throw new NotImplementedException(); }
public CarProfile Convert(CarProfileModel carProfile) { throw new NotImplementedException(); }
public async Task UpdateCarProfileTask(CarProfileModel carProfile) { await Task.Delay(2000); }