public async Task <IActionResult> CreateBook(BookCreationModel vm) { var bookId = await _booksManager.CreateBook(vm); return(CreatedAtRoute("GetBook", new { id = bookId }, vm)); }
public async Task <string> CreateBook(BookCreationModel vm) { var booksEntity = _mapper.Map <Books>(vm); booksEntity.Status = true; _booksReprository.CreateBook(booksEntity); if (!(await _booksReprository.SaveAsync())) { _logger.LogInformation("error log message"); throw new Exception("Creating an book failed on save."); } return(booksEntity.Id.ToString()); }
public ActionResult CreateBooking(BookCreationModel creationModel) { var model = new BookingDTO.Builder(Session["User"].ToString(), creationModel.Room, creationModel.Start, creationModel.End, creationModel.Priority).IsInternal(creationModel.IsInternal).Build(); try { this.scheduleService.CreateBooking(model); } catch (Exception ex) { throw new ArgumentException(ex.Message); } this.Notify("Booking successfully created"); return(View("~/Views/Notify/NotifyPage.cshtml", new { message = "Booking successfully created" })); }