public async Task <Booking> PutBooking(int id, Booking item) { Booking Sp = await _context.Bookings.FindAsync(id); Sp.Bookingid = item.Bookingid; Sp.CustomerId = item.CustomerId; Sp.ServiceProviderId = item.ServiceProviderId; Sp.Servicedate = item.Servicedate; Sp.Starttime = item.Starttime; Sp.Endtime = item.Endtime; Sp.Estimatedcost = item.Estimatedcost; Sp.Bookingstatus = item.Bookingstatus; Sp.Servicestatus = item.Servicestatus; Sp.Rating = item.Rating; _context.SaveChanges(); return(Sp); }
public Booking AddBooking(Booking booking) { try { if (booking.Id == 0) { _dbContext.bookings.Add(booking); _dbContext.SaveChanges(); return(booking); } else { _dbContext.Entry(booking).State = EntityState.Modified; _dbContext.SaveChanges(); return(booking); } } catch (Exception ex) { return(null); } }