public void Add(CourtBook book) { if (book.Client.Id == 0) { _clientService.Add(book.Client); } var courtBookEntity = new CourtBookEntity { CourtId = book.Court.Id, StartTime = book.StartTime, EndTime = book.EndTime, Price = book.Price, ReserveRequired = book.ReserveRequired, Reserve = book.Reserve, Paid = book.Paid, ClientId = book.Client.Id, Comment = book.Comment, UserId = book.User, }; _context.CourtBooks.AddObject(courtBookEntity); _context.SaveChanges(); book.Id = courtBookEntity.Id; }
private void Delete(CourtBook courtBook) { _context.CourtBooks.DeleteObject(new CourtBookEntity { Id = courtBook.Id }); _context.SaveChanges(); }
public void Update(CourtBook book) { if (book.Client.Id == 0) { _clientService.Add(book.Client); } var courtBookEntity = _context.CourtBooks.First(cb => cb.Id == book.Id); courtBookEntity = new CourtBookEntity { Id = book.Id, CourtId = book.Court.Id, StartTime = book.StartTime, EndTime = book.EndTime, Price = book.Price, ReserveRequired = book.ReserveRequired, Reserve = book.Reserve, Paid = book.Paid, ClientId = book.Client.Id, Comment = book.Comment, UserId = book.User, }; _context.SaveChanges(); }