public IEnumerable <Seminar> Get() { using (var context = new ApplikationDbContext()) { var seminars = context.Seminars.OrderBy(a => a.dateAndTime).Include(c => c.bookings).ToArray(); return(seminars); } }
public Seminar Get(int id) { using (var context = new ApplikationDbContext()) { var seminar = context.Seminars.Where(c => c.id == id).Include(o => o.bookings).FirstOrDefault(); return(seminar); } }
public IEnumerable <Booking> Get() { using (var context = new ApplikationDbContext()) { var bookings = context.Bookings.ToArray(); return(bookings); } }
public Booking Get(int id) { using (var context = new ApplikationDbContext()) { var booking = context.Bookings.Find(id); return(booking); } }
public void Delete(int id) { using (var context = new ApplikationDbContext()) { var seminarToDelete = context.Seminars.Find(id); context.Seminars.Remove(seminarToDelete); context.SaveChanges(); } }
public void Delete(int id) { using (var context = new ApplikationDbContext()) { var bookingToDelete = context.Bookings.Find(id); context.Bookings.Remove(bookingToDelete); context.SaveChanges(); } }
public void Put(int id, [FromBody] Booking booking) { using (var context = new ApplikationDbContext()) { var bookingToUpdate = context.Bookings.Find(id); bookingToUpdate.name = booking.name; bookingToUpdate.surname = booking.surname; bookingToUpdate.phone = booking.phone; bookingToUpdate.email = booking.email; context.Bookings.Update(bookingToUpdate); context.SaveChanges(); } }
public void Post([FromBody] BookingViewModel bookingVM) { using (var context = new ApplikationDbContext()) { var booking = new Booking { name = bookingVM.name, surname = bookingVM.surname, phone = bookingVM.phone, email = bookingVM.email, seminarId = bookingVM.seminarId, createdAt = DateTime.Now }; context.Bookings.Add(booking); context.SaveChanges(); } }
public void Post([FromBody] SeminarViewModel seminarVM) { using (var context = new ApplikationDbContext()) { var seminar = new Seminar { name = seminarVM.name, topic = seminarVM.topic, speaker = seminarVM.speaker, dateAndTime = seminarVM.dateAndTime, durationTime = seminarVM.durationTime, address = seminarVM.address, sal = seminarVM.sal, numberOfSeats = seminarVM.numberOfSeats, status = (Status)seminarVM.status }; context.Seminars.Add(seminar); context.SaveChanges(); } }
public void Put(int id, [FromBody] Seminar seminar) { using (var context = new ApplikationDbContext()) { var seminarToUpdate = context.Seminars.Find(id); seminarToUpdate.name = seminarToUpdate.name; seminarToUpdate.topic = seminar.topic; seminarToUpdate.speaker = seminar.speaker; seminarToUpdate.dateAndTime = seminar.dateAndTime; seminarToUpdate.durationTime = seminar.durationTime; seminarToUpdate.address = seminar.address; seminarToUpdate.sal = seminar.sal; seminarToUpdate.numberOfSeats = seminar.numberOfSeats; seminarToUpdate.status = (Status)seminar.status; context.Seminars.Update(seminarToUpdate); context.SaveChanges(); } }
public ComentController(ApplikationDbContext dbContext, IMemoryCache memoryCache) { _dbContext = dbContext; // dependecy injection _memoryCache = memoryCache; // dependecy injection }
public ComentController(ApplikationDbContext dbContext) { _dbContext = dbContext; // dependecy injection }