public bool UpdatePackageArrangements(arrangement_package arrangementObj) { Models.apartma2Entities entities = new Models.apartma2Entities(); try { Models.arrangement_package arrangementModel = entities.arrangement_package.FirstOrDefault(el => el.id.Equals(arrangementObj.id)); if (arrangementModel != null) { arrangementModel.id = arrangementObj.id; arrangementModel.title = arrangementObj.title; arrangementModel.description = arrangementObj.description; arrangementModel.max_resevations = arrangementObj.max_reservations.ToString(); arrangementModel.valid_to = arrangementObj.valid_to; arrangementModel.valid_from = arrangementObj.valid_from; arrangementModel.price = (float)arrangementObj.price; entities.Entry(arrangementModel).State = System.Data.Entity.EntityState.Modified; entities.SaveChanges(); return(true); } else { return(false); } } catch (Exception ex) { return(false); } }
public bool UpdateDiscoint(discount discountObj) { Models.apartma2Entities entities = new Models.apartma2Entities(); try { Models.discount discountModel = entities.discounts.FirstOrDefault(el => el.id.Equals(discountObj.id)); if (discountModel != null) { discountModel.id = discountObj.id; discountModel.code = discountObj.code; discountModel.title = discountObj.title; discountModel.valid_to = discountObj.valid_to; discountModel.valid_from = discountObj.valid_from; discountModel.discount_percentage = (float)discountObj.discount_percentage; entities.Entry(discountModel).State = System.Data.Entity.EntityState.Modified; entities.SaveChanges(); return(true); } else { return(false); } } catch (Exception ex) { return(false); } }
public bool UpdateBooking(booking bookingObj) { Models.apartma2Entities entities = new Models.apartma2Entities(); try { Models.booking bookingModel = entities.bookings.FirstOrDefault(el => el.id.Equals(bookingObj.id)); if (bookingModel != null) { bookingModel.id = bookingObj.id; bookingModel.date_from = bookingObj.date_from; bookingModel.date_to = bookingObj.date_to; bookingModel.status = bookingObj.status.ToString(); bookingModel.apartment = ApartmentTypeConverter.ApartmentObjToModel(bookingObj.apartment); //bookingModel.customer = ApartmentTypeConverter.CustomerObjToModel(bookingObj.customer); bookingModel.payment_method = ApartmentTypeConverter.PaymentObjToModel(bookingObj.payment); bookingModel.discount = ApartmentTypeConverter.DiscountObjToModel(bookingObj.discount); entities.Entry(bookingModel).State = System.Data.Entity.EntityState.Modified; entities.SaveChanges(); return(true); } else { return(false); } } catch (Exception ex) { return(false); } }
public int AddApartment(apartment apartmentObj) { try { Models.apartma2Entities entities = new Models.apartma2Entities(); Models.apartment apartmentModel = new Models.apartment { accessible = apartmentObj.accessible, air_conditioning = apartmentObj.air_conditioning, class_stars = apartmentObj.class_stars, description = apartmentObj.description, latitude = (float?)apartmentObj.latitude, longitude = (float?)apartmentObj.longitude, no_extra_beds = apartmentObj.no_extra_beds, no_single_beds = apartmentObj.no_single_beds, no_king_beds = apartmentObj.no_king_beds, tv = apartmentObj.tv, title = apartmentObj.title, pet_friendly = apartmentObj.pet_friendly, internet = apartmentObj.internet, kitchen = apartmentObj.kitchen }; entities.apartments.Add(apartmentModel); entities.SaveChanges(); return(apartmentModel.id); } catch (Exception ex) { return(-1); } }
public int MakeBooking(string user_trr, int apartmentId, int dateFrom, int dateTo, int package_arrangment_id, string discountCode, bool bank_payment) { Models.apartma2Entities entities = new Models.apartma2Entities(); try { Models.apartment apartmentModel = entities.apartments.FirstOrDefault(el => el.id.Equals(apartmentId)); if (apartmentModel != null) { Models.payment_method method = new Models.payment_method(); method.bank_payment = bank_payment; // true -> e-bull; false -> card method.card_number = user_trr.ToString(); Models.booking newBooking = new Models.booking(); newBooking.customer_trr = user_trr; newBooking.apartment_idapartment = apartmentId; newBooking.date_from = dateFrom; newBooking.date_to = dateTo; newBooking.payment_method = method; if (bank_payment) { newBooking.status = "pending"; } else { newBooking.status = "paid"; } Models.arrangement_package arrangementModel = entities.arrangement_package.FirstOrDefault(el => el.id.Equals(package_arrangment_id)); Models.discount discountModel = entities.discounts.FirstOrDefault(el => el.code.Equals(discountCode)); if (arrangementModel != null) { newBooking.arrangement_package_id = arrangementModel.id; } if (discountModel != null) { newBooking.discounts_id = discountModel.id; } entities.bookings.Add(newBooking); entities.SaveChanges(); return(newBooking.id); } else { return(-1); } } catch (Exception ex) { return(-1); } }
public int AddDiscount(discount discountObj) { Models.apartma2Entities entities = new Models.apartma2Entities(); try { Models.discount discountModel = ApartmentTypeConverter.DiscountObjToModel(discountObj); entities.discounts.Add(discountModel); entities.SaveChanges(); return(discountModel.id); } catch (Exception ex) { return(-1); } }
public int AddPackageArrangments(arrangement_package arrangmentObj) { Models.apartma2Entities entities = new Models.apartma2Entities(); try { Models.arrangement_package arrangmentModel = ApartmentTypeConverter.ArrangmentObjToModel(arrangmentObj); entities.arrangement_package.Add(arrangmentModel); entities.SaveChanges(); return(arrangmentModel.id); } catch (Exception ex) { return(-1); } }
public bool DeleteDiscount(int discountId) { Models.apartma2Entities entities = new Models.apartma2Entities(); try { Models.discount discountModel = entities.discounts.FirstOrDefault(el => el.id.Equals(discountId)); if (discountModel != null) { entities.Entry(discountModel).State = System.Data.Entity.EntityState.Deleted; entities.SaveChanges(); return(true); } else { return(false); } } catch (Exception ex) { return(false); } }
public bool DeletePackageArrangments(int arrangementId) { Models.apartma2Entities entities = new Models.apartma2Entities(); try { Models.arrangement_package arrangementModel = entities.arrangement_package.FirstOrDefault(el => el.id.Equals(arrangementId)); if (arrangementModel != null) { entities.Entry(arrangementModel).State = System.Data.Entity.EntityState.Deleted; entities.SaveChanges(); return(true); } else { return(false); } } catch (Exception ex) { return(false); } }
public bool UpdateApartment(apartment apartmentObj) { Models.apartma2Entities entities = new Models.apartma2Entities(); try { Models.apartment apartmentModel = entities.apartments.FirstOrDefault(el => el.id.Equals(apartmentObj.id)); if (apartmentModel != null) { apartmentModel.accessible = apartmentObj.accessible; apartmentModel.air_conditioning = apartmentObj.air_conditioning; apartmentModel.class_stars = apartmentObj.class_stars; apartmentModel.description = apartmentObj.description; apartmentModel.latitude = (float?)apartmentObj.latitude; apartmentModel.longitude = (float?)apartmentObj.longitude; apartmentModel.no_extra_beds = apartmentObj.no_extra_beds; apartmentModel.no_single_beds = apartmentObj.no_single_beds; apartmentModel.no_king_beds = apartmentObj.no_king_beds; apartmentModel.tv = apartmentObj.tv; apartmentModel.title = apartmentObj.title; apartmentModel.pet_friendly = apartmentObj.pet_friendly; apartmentModel.internet = apartmentObj.internet; apartmentModel.kitchen = apartmentObj.kitchen; entities.Entry(apartmentModel).State = System.Data.Entity.EntityState.Modified; entities.SaveChanges(); return(true); } else { return(false); } } catch (Exception ex) { return(false); } }
public bool CancleBooking(int bookingId) { Models.apartma2Entities entities = new Models.apartma2Entities(); try { Models.booking booking = entities.bookings.FirstOrDefault(el => el.id.Equals(bookingId)); if (booking != null) { booking.status = "cancelled"; entities.Entry(booking).State = System.Data.Entity.EntityState.Modified; entities.SaveChanges(); return(true); } else { return(false); } } catch (Exception ex) { return(false); } }