public List <RentRequestsEntity> GetAllRentRequestsByTransportDeviceToBorrow(BoatsEntity DeviceToBorrow)/*Függvény, ami visszaad egy listát, ami tartalmazza, hogy az adott hajónak, milyen kölcsönzési kérelmei vannak vannak*/ { var linqQuery = from row in dbc.RentRequests where row.DeviceToBorrow.Equals(DeviceToBorrow) select row; List <RentRequestsEntity> RentRequestsList = linqQuery.ToList(); return(RentRequestsList); }
public int GetIncomeBoatRentalsByWeekAndBoat(int week, int id) { DateTimeFormatInfo dfi = DateTimeFormatInfo.CurrentInfo; Calendar calendar = dfi.Calendar; var linqQuery = from row in dbc.BoatRentals where row.FKRentedBoat.BoatId.Equals(id) select row; List <BoatRentalsEntity> BoatRentalsList = linqQuery.ToList(); int RentalCount = 0; int Income = 0; for (int i = 0; i < BoatRentalsList.Count; i++) { if (calendar.GetWeekOfYear(BoatRentalsList[i].StartingDate, dfi.CalendarWeekRule, DayOfWeek.Monday) .Equals(week)) { List <BoatRentalsEntity> BoatRentalsList2 = linqQuery.ToList(); BoatsDaoImpl boatsDaoImpl = new BoatsDaoImpl(); BoatsEntity boatsEntity = boatsDaoImpl.GetBoatsById(id); for (int g = 0; g < BoatRentalsList2.Count; g++) { Income += (BoatRentalsList[i].EndDate - BoatRentalsList[i].StartingDate).Days * Convert.ToInt32(boatsEntity.DailyPrice); } } } return(Income); }
private void UpdateBoat() { dbc = AliveContext.Context; BoatsEntity boatData = dbc.Boats.SingleOrDefault(m => m.BoatId.Equals(BoatId)); boatData.BoatId = this.BoatId; boatData.BoatName = this.BoatName; boatData.BoatType = this.BoatType; boatData.DailyPrice = this.DailyPrice; boatData.WhereIsNowTheBoat = this.WhereIsNowTheBoat; boatData.IsLoan = this.IsLoan; boatData.MaxPerson = this.MaxPerson; boatData.MaxSpeed = this.MaxSpeed; boatData.DiveDepth = this.DiveDepth; boatData.Consumption = this.Consumption; boatData.YearOfManufacture = this.YearOfManufacture; boatData.BoatLength = this.BoatLength; boatData.BoatWidth = this.BoatWidth; boatData.BoatImage = this.BoatImage; dbc.SaveChanges(); FeedbackMessage = "Adatok sikeresen módosítva!"; ServiceStatus = Status.OK; // it must be a method if (!string.IsNullOrEmpty(FeedbackMessage) && !string.IsNullOrWhiteSpace(FeedbackMessage)) { new PrintMessageBox(FeedbackMessage, ServiceStatus); } }
GetBoatRentalsByBoat( BoatsEntity RentedBoat) /*Függvény, ami visszaad egy listát, ami tartalmazza, hogy az adott hajóhoz milyen kölcsönzések vannak*/ { var linqQuery = from row in dbc.BoatRentals where row.FKRentedBoat.Equals(RentedBoat) select row; List <BoatRentalsEntity> BoatRentalsList = linqQuery.ToList(); return(BoatRentalsList); }
public MembersEntity getMemberByBoat(BoatsEntity boat) { var linqQuery = from row in dbc.Members where row.Email.Equals(boat.FKOwner.Email) select row; List <MembersEntity> membersList = linqQuery.ToList(); MembersEntity member = GetSingleResultWithoutExc(membersList); return(member); }
public BookingService(string whoBorrowsEmail, DateTime from, DateTime to, BoatsEntity boatToBorrow, string fromWhere, string toWhere, int numberOfPersons) { this.fromWhere = fromWhere; this.toWhere = toWhere; this.numberOfPersons = numberOfPersons; this.from = from; this.to = to; this.boatToBorrow = boatToBorrow; this.whoBorrowsEmail = whoBorrowsEmail; dbc = AliveContext.Context; TryToBook(); }
private void LoadSelectedBoat() { BoatsDao boatsDao = new BoatsDaoImpl(); BoatsEntity boat = boatsDao.GetBoatsById(Convert.ToInt32(id)); MembersDao membersDao = new MembersDaoImpl(); MembersEntity member = membersDao.getMemberByBoat(boat); ResponseMessage.Add("BoatName", boat.BoatName); ResponseMessage.Add("BoatImage", boat.BoatImage); ResponseMessage.Add("BoatType", boat.BoatType); ResponseMessage.Add("DailyPrice", Convert.ToString(boat.DailyPrice)); ResponseMessage.Add("WhereIsNowTheBoat", boat.WhereIsNowTheBoat); ResponseMessage.Add("IsLoan", Convert.ToString(boat.IsLoan)); ResponseMessage.Add("MaxPerson", Convert.ToString(boat.MaxPerson)); ResponseMessage.Add("MaxSpeed", Convert.ToString(boat.MaxSpeed)); ResponseMessage.Add("DiveDepth", Convert.ToString(boat.DiveDepth)); ResponseMessage.Add("Consumption", Convert.ToString(boat.Consumption)); ResponseMessage.Add("YearOfManufacture", Convert.ToString(boat.YearOfManufacture)); ResponseMessage.Add("BoatLength", Convert.ToString(boat.BoatLength)); ResponseMessage.Add("BoatWidth", Convert.ToString(boat.BoatWidth)); /*Member Adatok, ha az is kellene, például a foglalásnál*/ ResponseMessage.Add("email", member.Email); ResponseMessage.Add("password", member.Password); ResponseMessage.Add("permission", member.Permission.ToString()); char[] delimiter = { ' ' }; string[] memberName = member.MemberName.Split(delimiter); string[] firstnameaArray = memberName.Take(memberName.Count() - 1).ToArray(); string firstname = string.Join(" ", firstnameaArray); string lastname = memberName.Last(); ResponseMessage.Add("firstname", firstname); ResponseMessage.Add("lastname", lastname); ResponseMessage.Add("country", member.Country); ResponseMessage.Add("city", member.City); ResponseMessage.Add("street", member.Street); ResponseMessage.Add("houseNumber", member.HouseNumber); ResponseMessage.Add("MemberImage", member.MemberImage); /* ^^Member Adatok, ha az is kellene, például a foglalásnál*/ }
public void RegisterService(ref BoatsEntity boatsEntity) { dbc = AliveContext.Context; dbc.Boats.Add(boatsEntity); dbc.SaveChanges(); FeedbackMessage = "Sikeres regisztráció!"; ServiceStatus = Status.OK; // it must be a method if (!string.IsNullOrEmpty(FeedbackMessage) && !string.IsNullOrWhiteSpace(FeedbackMessage)) { new PrintMessageBox(FeedbackMessage, ServiceStatus); } }
public int GetIncomeBoatRentalsByMonthAndBoat(int month, int id) { var linqQuery = from row in dbc.BoatRentals where (row.StartingDate.Month.Equals(month) & row.FKRentedBoat.BoatId.Equals(id)) select row; List <BoatRentalsEntity> BoatRentalsList = linqQuery.ToList(); BoatsDaoImpl boatsDaoImpl = new BoatsDaoImpl(); BoatsEntity boatsEntity = boatsDaoImpl.GetBoatsById(id); int Income = 0; for (int i = 0; i < BoatRentalsList.Count; i++) { Income += (BoatRentalsList[i].EndDate - BoatRentalsList[i].StartingDate).Days * Convert.ToInt32(boatsEntity.DailyPrice); } return(Income); }
// esemeny, amely akkor kovetkezik be, ha a UserControlban masik elemet valasztottunk // ekkor toltodik fel a SelectedBoatIndex a megfelelo ertekkel private void SelectionChanged(object sender, RoutedEventArgs e) { // kivalasztott hajo entity BoatsEntity selectedBoat = LoadBookableBoatsService.BookableBoats[SelectedBoatIndex]; this.selectedBoat = selectedBoat; tbOwnerName.Text = selectedBoat.FKOwner.MemberName; tbOwnerEmail.Text = selectedBoat.FKOwner.Email; tbOwnerResidency.Text = selectedBoat.FKOwner.Country + ", " + selectedBoat.FKOwner.City + ", " + selectedBoat.FKOwner.Street + " " + selectedBoat.FKOwner.HouseNumber + "."; LoadUserDataService loadUserDataService = new LoadUserDataService(whoBorrowsEmail); imgOwnerPicture.Tag = loadUserDataService.ResponseMessage["MemberImage"]; var uri = new Uri(Convert.ToString(imgOwnerPicture.Tag), UriKind.Absolute); var bitmap = new BitmapImage(uri); imgOwnerPicture.Source = bitmap; tbBoatName.Text = selectedBoat.BoatName; tbBoatPrice.Text = selectedBoat.DailyPrice.ToString(); tbBoatConsumption.Text = selectedBoat.Consumption.ToString(); tbBoatType.Text = selectedBoat.BoatType; tbBoatManpower.Text = selectedBoat.MaxPerson.ToString(); tbBoatSpeed.Text = selectedBoat.MaxSpeed.ToString(); tbBoatWidth.Text = selectedBoat.BoatWidth.ToString(); tbBoatLenght.Text = selectedBoat.BoatLength.ToString(); tbBoatYear.Text = selectedBoat.YearOfManufacture.ToString(); tbBoatDept.Text = selectedBoat.DiveDepth.ToString(); tbBoatPlace.Text = selectedBoat.WhereIsNowTheBoat; LoadSelectedBoatService loadSelectedBoatService = new LoadSelectedBoatService(selectedBoat.BoatId.ToString()); imgBoatPicture.Source = LoadImage(loadSelectedBoatService.ResponseMessage["BoatImage"]); imgBoatPicture.Tag = loadSelectedBoatService.ResponseMessage["BoatImage"]; //imgBoatPicture = Image; e.Handled = true; }
public RegisterBoatService(ref BoatsEntity boatsEntity) { RegisterService(ref boatsEntity); }
private void Register_Click(object sender, RoutedEventArgs e) { try { Validator registerValidator = new Validator(); registerValidator.ValidationComponents.Add(new EmptyFieldValidator(tbBoatName.Text, "Név")); registerValidator.ValidationComponents.Add(new EmptyFieldValidator(tbBoatType.Text, "Típus")); //registerValidator.ValidationComponents.Add(new EmptyFieldValidator(imgBoatPicture.Tag, "fénykép")); registerValidator.ValidationComponents.Add(new EmptyFieldValidator(tbBoatLenght.Text, "Hossz")); registerValidator.ValidationComponents.Add(new EmptyFieldValidator(tbBoatWidth.Text, "Szélesség")); registerValidator.ValidationComponents.Add(new EmptyFieldValidator(tbBoatConsumption.Text, "Fogyasztás")); registerValidator.ValidationComponents.Add(new EmptyFieldValidator(tbBoatPrice.Text, "Ár")); registerValidator.ValidationComponents.Add(new EmptyFieldValidator(tbBoatDept.Text, "Merülési mélység")); registerValidator.ValidationComponents.Add(new EmptyFieldValidator(tbBoatManpower.Text, "Max. Létszám")); registerValidator.ValidationComponents.Add(new EmptyFieldValidator(tbBoatSpeed.Text, "Max. sebesség")); registerValidator.ValidationComponents.Add(new EmptyFieldValidator(tbBoatPlace.Text, "Tartózkodási helye")); registerValidator.ValidationComponents.Add(new EmptyFieldValidator(tbBoatYear.Text, "Gyártási év")); registerValidator.ValidateElements(); BoatsDao boatsDao = new BoatsDaoImpl(); BoatsEntity boatsEntity = new BoatsEntity(); dbc = AliveContext.Context; boatsEntity.BoatId = dbc.Boats.OrderByDescending(u => u.BoatId).FirstOrDefault().BoatId; if (imgBoatPicture.Tag == null) { imgBoatPicture.Tag = "stock_boat_image.png"; } boatsEntity.BoatImage = imgBoatPicture.Tag.ToString(); boatsEntity.BoatLength = Convert.ToInt32(tbBoatLenght.Text); boatsEntity.BoatWidth = Convert.ToInt32(tbBoatWidth.Text); boatsEntity.BoatName = tbBoatName.Text; //boatsEntity.BoatRentals = null; boatsEntity.BoatType = tbBoatType.Text; boatsEntity.Consumption = Convert.ToInt32(tbBoatConsumption.Text); boatsEntity.DailyPrice = Convert.ToInt32(tbBoatPrice.Text); boatsEntity.DiveDepth = Convert.ToInt32(tbBoatDept.Text); MembersDao membersDao = new MembersDaoImpl(); MembersEntity member = membersDao.getMemberByEmail(email); boatsEntity.FKOwner = member; boatsEntity.IsLoan = tbIsLoan.IsChecked ?? false; boatsEntity.MaxPerson = Convert.ToInt32(tbBoatManpower.Text); boatsEntity.MaxSpeed = Convert.ToInt32(tbBoatSpeed.Text); boatsEntity.WhereIsNowTheBoat = tbBoatPlace.Text; boatsEntity.YearOfManufacture = Convert.ToInt32(tbBoatYear.Text); RegisterBoatService registerService = new RegisterBoatService(ref boatsEntity); MyBoatsAndDevicesWindow ToMyBoatsAndDevicesWindow = new MyBoatsAndDevicesWindow(email); //ToMyBoatsAndDevicesWindow.Show(); this.Close(); } catch (Exception ex) { new ExceptionToConsole(ex); } }