public async Task <ActionResult <int> > PostClientBooking(ClientBookingDto booking) { if (ModelState.IsValid) { ClientBooking clientBooking = mapper.Map <ClientBooking>(booking); var bookingId = await clientRepository.AddBookingAsync(clientBooking); if (bookingId > 0) { int logId = await emailSender.SendEmailAsync(bookingId); if (logId > 0) { return(Ok(bookingId)); } } else { if (bookingId == -1) { return(NoContent()); } return(NotFound()); } } return(BadRequest()); }
public async Task <bool> UpdateBookingAsync(ClientBooking Booking) { db.ClientBooking.Update(Booking); await db.SaveChangesAsync(); return(true); }
public int ClientBooking([FromBody] ClientBooking bookingJsonstring) { try { dataHelper.ClientBooking(bookingJsonstring); return(1); } catch (System.Exception ex) { throw new Exception(ex.InnerException.ToString()); return(0); } }
public async Task <int> AddBookingAsync(ClientBooking Booking) { int count = db.ClientBooking.Where(C => C.ClientId == Booking.ClientId && C.Date == Booking.Date).Count(); if (count < 4) { await db.ClientBooking.AddAsync(Booking); await db.SaveChangesAsync(); return(Booking.Id); } return(-1); }
public async Task <IActionResult> PutClientBooking(ClientBookingDto booking) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } ClientBooking updatedBooking = mapper.Map <ClientBooking>(booking); bool result = await clientRepository.UpdateBookingAsync(updatedBooking); if (result) { return(NoContent()); } return(NotFound()); }
internal void ClientBooking(ClientBooking clientBooking) { clientBookings.Add(clientBooking); }