public Reservation SaveReservation(Reservation reservation) { _context.Reservations.Add(reservation); _context.SaveChanges(); return _context.Reservations.FirstOrDefault( x => x.TimeSlot == reservation.TimeSlot && x.Email == reservation.Email); }
public MailMessage GenerateCancellationConfirmation(Reservation reservation) { var mail = new MailMessage("*****@*****.**", reservation.Email); mail.IsBodyHtml = true; string subject = "Avbokningsbekräftelse - " + reservation.Restaurant.Id; mail.Subject = subject; var body = "<h2>Hej " + reservation.Name + "!</h2><br/>"; body += "Du har avbokat ditt bord på restaurang <b>" + reservation.Restaurant.Id + "</b> den " + reservation.TimeSlot + " för " + reservation.PersonCount + " personer."; mail.Body = body; return mail; }
public MailMessage GenerateReservationConfirmation(Reservation reservation) { var mail = new MailMessage("*****@*****.**", reservation.Email); mail.IsBodyHtml = true; string subject = "Bokningsbekräftelse - " + reservation.Restaurant.Name; mail.Subject = subject; var body = "<h2>Hej " + reservation.Name + "!</h2><br/>"; body += "Du har bokat bord på restaurang <b>" + reservation.Restaurant.Name + "</b> den " + reservation.TimeSlot + " för " + reservation.PersonCount + " personer."; mail.Body = body; SmtpClient client = new SmtpClient(); client.PickupDirectoryLocation = ""; return mail; }
public ActionResult Create(CreateReservationModel model) { if (ModelState.IsValid) { Reservation r = new Reservation(); r.Name = model.Name; r.Email = model.Email; r.Telephone = model.Telephone; r.PersonCount = model.PersonCount; r.Restaurant = _reservationService.GetRestaurant(model.RestaurantId); r.TimeSlot = model.Date.AddHours(model.Time); int reservationId = _reservationService.SaveReservation(r).Id; return RedirectToAction("Details", "Reservation", new { id = reservationId}); } return View(model); }
public Reservation SaveReservation(Reservation reservation) { //Detta ska spara reservationen genom repository var res = _repository.SaveReservation(reservation); //Om repository returnerar något annat än null har det lyckats if (res != null) { var emailService = new EmailService(); //Generera och skapa email emailService.Send(emailService.GenerateReservationConfirmation(reservation)); } //Skicka tillbaka reservationen (för att kunna visa bekräftelse på skärmen t.ex.) return res; }
public void DeleteReservation(Reservation reservation) { _repository.DeleteReservation(reservation); }
public Reservation UpdateReservation(Reservation reservation) { return _repository.UpdateReservation(reservation); }
public Reservation UpdateReservation(Reservation reservation) { throw new NotImplementedException(); }
public Reservation DeleteReservation(Reservation reservation) { _context.Reservations.Remove(reservation); _context.SaveChanges(); return null; }