コード例 #1
0
        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());
        }
コード例 #2
0
        public async Task <bool> UpdateBookingAsync(ClientBooking Booking)
        {
            db.ClientBooking.Update(Booking);
            await db.SaveChangesAsync();

            return(true);
        }
コード例 #3
0
 public int ClientBooking([FromBody] ClientBooking bookingJsonstring)
 {
     try {
         dataHelper.ClientBooking(bookingJsonstring);
         return(1);
     } catch (System.Exception ex) {
         throw new Exception(ex.InnerException.ToString());
         return(0);
     }
 }
コード例 #4
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);
        }
コード例 #5
0
        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());
        }
コード例 #6
0
 internal void ClientBooking(ClientBooking clientBooking)
 {
     clientBookings.Add(clientBooking);
 }