public ActionResult EditOrCreate(int?id) { TakedBooksDTO takedBooks = new TakedBooksDTO(); if (id != null) { takedBooks = takedBooksService.GetTakedBooks(id); } return(View(takedBooks)); }
public void MakeTakedBooks(TakedBooksDTO orderDto) { TakedBooks takedBooks = new TakedBooks { BookId = orderDto.BookId, UserId = orderDto.UserId, }; db.TakedBooks.Create(takedBooks); db.Save(); }
public ActionResult EditOrCreate(TakedBooks takedBooks) { if (takedBooks.id != 0) { var tempTakedBooks = takedBooksService.GetTakedBooks(takedBooks.id); tempTakedBooks.BookId = takedBooks.BookId; tempTakedBooks.UserId = takedBooks.UserId; takedBooksService.SaveUpdate(takedBooks); } else { var takedBookDto = new TakedBooksDTO { BookId = takedBooks.BookId, UserId = takedBooks.UserId }; takedBooksService.MakeTakedBooks(takedBookDto); } return(RedirectToActionPermanent("Index", "TakedBooks")); }