public async Task <ActionResult <ReservationType> > PostReservationType(ReservationType reservationType) { _context.ReservationType.Add(reservationType); await _context.SaveChangesAsync(); return(CreatedAtAction("GetReservationType", new { id = reservationType.Id }, reservationType)); }
public List <ReservationType> GetReservationTypeList() { try { List <ReservationType> reservationTypeList = new List <ReservationType>(); using (var context = new BiografContext()) { foreach (var reservationType in context.ReservationTypes) { ReservationType reservationTypeModel = new ReservationType() { Id = reservationType.Id, Type = reservationType.Type }; reservationTypeList.Add(reservationType); } } return(reservationTypeList); } catch (Exception ex) { return(null); } }
public async Task <IActionResult> PutReservationType(int id, ReservationType reservationType) { if (id != reservationType.Id) { return(BadRequest()); } _context.Entry(reservationType).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ReservationTypeExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public ActionResult Create(ReservationTypeViewModel reservation) { try { if (!ModelState.IsValid) { return(View()); } var absencType = new ReservationType { Id = reservation.Id, Name = reservation.Name, Number = reservation.Number }; var isSuccess = _repo.Create(absencType); if (!isSuccess) { ModelState.AddModelError("", "Something went wrong"); return(View(reservation)); } return(RedirectToAction(nameof(Index))); } catch { return(View()); } }
//Create a List of Reservation public List <ReservationType> ListOfResevations() { // randomly choose a hotel ID, starting date, number of days, and room type List <ReservationType> list = new List <ReservationType>(); ReservationType reserve; //String hotelID; String roomType; int NumDays; int customerId = 1; String date; Random rnd = new Random(Environment.TickCount); string hotelID; for (int i = 0; i < 30; i++) { String custId = "000" + customerId; Thread.Sleep(50); hotelID = random.randomHotelId(); roomType = random.randomRoomId(); NumDays = random.randomNumOfDays(); date = random.randomStarDate(); reserve = new ReservationType(hotelID, date, NumDays, custId, roomType); list.Add(reserve); customerId++; } return(list); }
// GET: ReservationTypeController/Delete/5 public ActionResult Delete(int id, ReservationType reservationType) { var reservation = _context.ReservationTypes.Find(id); return(View(reservation)); }
public IHttpActionResult PutReservationType(int id, ReservationType reservationType) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != reservationType.ReservationTypeID) { return(BadRequest()); } db.Entry(reservationType).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!ReservationTypeExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public ActionResult Edit(int id, ReservationTypeViewModel model) { try { if (!ModelState.IsValid) { ModelState.AddModelError("", "Something went wrong"); return(View(model)); } var ReservationType = new ReservationType { Id = model.Id, Name = model.Name, Number = model.Number }; var isSuccess = _repo.Update(ReservationType); if (!isSuccess) { ModelState.AddModelError("", "Something went wrong"); return(View(model)); } return(RedirectToAction(nameof(Index))); } catch { ModelState.AddModelError("", "Something went wrong"); return(View()); } }
public async Task <IActionResult> Edit(string id, [Bind("Id,Name,AccessNumber")] ReservationType reservationType) { if (id != reservationType.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(reservationType); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ReservationTypeExists(reservationType.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(reservationType)); }
public static void SetReservationType(this Reservation reservation, ReservationType type) { using (var context = new AirportContext()) { reservation.ReservationType = type; context.SaveChanges(); } }
public string MakeReservation(Reservation resItem) { ReservationType rtype = ReservationType.GetType(resItem.Type); if (rtype == ReservationType.LTWeekly || rtype == ReservationType.LTWeeklyWorkHrs) { resItem.EndDate = resItem.StartDate.AddDays(7); } else if (rtype == ReservationType.LTMonthly || rtype == ReservationType.LTMonthlyWorkHrs) { resItem.EndDate = resItem.StartDate.AddDays(30); } else { resItem.EndDate = resItem.StartDate.AddDays(1); } resItem.EndDate = resItem.EndDate.AddSeconds(-1); // 12.59.59 PM Local time on the last day of reservation using (var context = new MobileServiceContext()) { try { ParkingLot parkingLot = context.ParkingLots.Find(resItem.LotId); string sql = "SELECT COUNT(*) FROM Reservation rr WHERE rr.LotId = @lotid and @startDt <= rr.EndDate and @endDt >= rr.StartDate"; SqlParameter[] parms = new SqlParameter[] { new SqlParameter("@lotid", resItem.LotId), new SqlParameter("@startDt", resItem.StartDate), new SqlParameter("@endDt", resItem.EndDate), }; int reserved = context.Database.SqlQuery <int>(sql, parms).FirstOrDefault(); if (reserved >= parkingLot.Capacity) { return("Parking not available for the selected date(s)"); } PriceModel priceModel = context.PriceModels.Find(resItem.PriceModelId); resItem.AdvancePaid = priceModel.GetAdvanceCharge(resItem.Type); Utils.CreateStripeCharge(resItem.AdvancePaid.Value, parkingLot.Name, resItem.ConfNumAdvance); parkingLot.Reserved++; context.Reservations.Add(resItem); context.SaveChanges(); } catch (Exception ex) { throw ServerUtils.BuildException(ex); } } return(null); }
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) { _type = (ReservationType)Enum.Parse(typeof(ReservationType), comboBox1.Text); List <SiteEntity> sites = new SiteEntityManager().Sites(_type); comboBox2.DataSource = sites; comboBox2.DisplayMember = "SiteName"; comboBox2.ValueMember = "SiteCode"; }
public static void SetTypeToReservation(int reservationId, ReservationType type) { using (var context = new AirportContext()) { context.Reservations .FirstOrDefault(r => r.ReservationId == reservationId) .ReservationType = type; context.SaveChanges(); } }
public IActionResult Create(ReservationType reservationType, string id, int numberOfTourists) { var inputModel = new ReservationCreateInputModel { ReservationType = reservationType, NumberOfTourists = numberOfTourists, ProductId = id, }; return(this.View(inputModel)); }
public async Task <ActionResult> Create([Bind("ReservationName,AccessNumber")] ReservationType reservationType) { if (ModelState.IsValid) { _context.Add(reservationType); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(reservationType)); }
public IHttpActionResult GetReservationType(int id) { ReservationType reservationType = db.ReservationType.Find(id); if (reservationType == null) { return(NotFound()); } return(Ok(reservationType)); }
public IHttpActionResult PostReservationType(ReservationType reservationType) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.ReservationType.Add(reservationType); db.SaveChanges(); return(CreatedAtRoute("DefaultApi", new { id = reservationType.ReservationTypeID }, reservationType)); }
private bool isIncorrectDate(ReservationType reservation, string date, int numDays) { DateTime startDate = DateTime.ParseExact(date, "yyyyMMdd", CultureInfo.InvariantCulture); DateTime finalInvDate = DateTime.ParseExact(inventory[inventory.Count - 1].Date, "yyyyMMdd", CultureInfo.InvariantCulture); if (startDate.AddDays(numDays) > finalInvDate) { reservation.result = ReservationType.ReservationResultType.RoomNotAvailable; return(true); } return(false); }
public async Task <ActionResult> Edit(int id, ReservationType reservationType) { if (ModelState.IsValid) { _context.Update(reservationType); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(reservationType)); }
public Reservation(Guid pId, string pUserFrom, string pCustomerName, string pPhone, DateTime pArriveTime, string pTableName, int pSeat, ReservationType pType, ReservationState pState) { id = pId; userFrom = pUserFrom; customerName = pCustomerName; phone = pPhone; arriveTime = pArriveTime; tableName = pTableName; seat = pSeat; type = pType; state = pState; }
public RentPageViewModel(INavigationService navigationService, IApiService apiService, IPageDialogService dialogService, IAuthService authorizationService) : base(navigationService) { NavigationService = navigationService; ApiService = apiService; DialogService = dialogService; AuthorizationService = authorizationService; BlackoutDates = new ObservableCollection <DateTime>(); ReservationTypeList = new ObservableCollection <ReservationType>(); NewReservation = new Reservation(); Post = new Post(); SelectedReservationType = new ReservationType(); RentCommand = new DelegateCommand(Rent); }
public async Task <ActionResult> AddType(ReservationType NameReservation) { try { _context.ReservationsType.Add(NameReservation); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } catch { return(View()); } }
public async Task <ActionResult> UpdateType(int id, ReservationType UpdtReservation) { try { _context.Update(UpdtReservation); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } catch { return(View()); } }
public IHttpActionResult DeleteReservationType(int id) { ReservationType reservationType = db.ReservationType.Find(id); if (reservationType == null) { return(NotFound()); } db.ReservationType.Remove(reservationType); db.SaveChanges(); return(Ok(reservationType)); }
public ReservationType generation() { String sd = monthCalendar1.SelectionStart.ToString("yyyyMMdd"); String cusID; randomGeneration ran = new randomGeneration(); cusID = ran.getCustID(); ReservationType reservation = new ReservationType(hotelID(), sd, getDateDifference(), cusID, hotelRoom()); if (r.ReserveRoom(reservation)) { String year = reservation.startDate.Substring(0, 4); String month = reservation.startDate.Substring(4, 2); String day = reservation.startDate.Substring(6, 2); MessageBox.Show("The reservation was: " + reservation.result + ".Customer " + reservation.customerId + " RESERVERD " + reservation.roomType + " ROOM for " + reservation.numDays + " days Starting " + month + "/" + day + "/" + year + " - $" + reservation.cost); String email = EmailBox.Text; Console.WriteLine(email); MailMessage message = new MailMessage(); SmtpClient client = new SmtpClient(); client.Host = "smtp.gmail.com"; client.Port = 587; client.EnableSsl = true; client.Credentials = new NetworkCredential("*****@*****.**", "danielandmaria"); String boo = "Hello " + nameBox.Text + "!!!\n You just reserved a room in " + HotelFactory.GetHotelName(reservation.hotelId) + "\n " + "Your reservation starts: " + month + "/" + day + "/" + year + " for " + reservation.numDays + " nights " + ". The total cost of your reservation is $" + reservation.cost + ".\nTo keep track of your reservation: " + reservation.reservationId + "\n We hope you have an amazing time and thanks for choosing us!!."; try { MailMessage mail = new MailMessage(); mail.From = new MailAddress("*****@*****.**"); mail.To.Add(email); mail.Subject = "Information from your reservation!!"; mail.Body = boo; client.Send(mail); } catch (Exception ex) { MessageBox.Show("Cannot email the reservation"); //MessageBox.Show(ex.ToString()); } } else { MessageBox.Show("Cannot reserve because: " + reservation.result); } return(reservation); }
private void FinalizeCheckout(MobileServiceContext context, Reservation rItem, DateTimeOffset checkoutTime) { ReservationType rtype = ReservationType.GetType(rItem.Type); if (rtype == ReservationType.ST) { rItem.ActualCheckout = checkoutTime; } else { rItem.ActualCheckin = rItem.ActualCheckout = null; } context.SaveChanges(); }
private BookingType MapType(ReservationType type) { switch (type) { case ReservationType.Event: return(BookingType.Event); case ReservationType.Group: return(BookingType.Group); case ReservationType.RackRate: return(BookingType.RackRate); case ReservationType.Usual: return(BookingType.Usual); default: return(BookingType.Usual); } }
private static DateTime GetPayByDate(ReservationType type, DateTime start, DateTime end) { switch (type) { case ReservationType.Conventional: return(end); case ReservationType.Incentive: return(end); case ReservationType.Prepaid: return(start); case ReservationType.SixtyDay: return(start.AddDays(-30)); // 30 days before start default: throw new NotImplementedException("Unknown ReservationType: " + type); } }
// GET: ReservationType/Edit/5 public ActionResult Edit(int id) { if (!_repo.IsExist(id)) { return(NotFound()); } var AbsenceType = _repo.GetById(id); var model = new ReservationType { Id = AbsenceType.Id, NameType = AbsenceType.NameType, AccessNumber = AbsenceType.AccessNumber }; return(View(model)); }
public decimal GetAdvanceCharge(int type) { decimal? rt; ReservationType rtype = ReservationType.GetType(type); if (rtype == ReservationType.ST) { rt = GetMinimumCharge(); } else { rt = GetRateforType(rtype); } return(rt.Value); }
public async Task <ApiResultLite> CreateAsync(string name) { ReservationType rvt = new ReservationType() { Name = name }; _context.ReservationTypes.Add(rvt); int result = await _context.SaveChangesAsync(); if (result == 0) { return(new ApiErrorResultLite("Thêm thất bại")); } return(new ApiSuccessResultLite("Thêm thành công")); }