public async Task <bool> UpdateBorrow(Guid id, UpdateBorrowDto model, string fields) { var borrow = await _service.Query(id, false); borrow.UpdateTime = DateTime.Now; return(await _service.Update(CommonClass.SetModelValue(model, borrow, fields))); }
public async Task HandleAsync(ReturnBook command) { var now = DateTime.UtcNow; await _borrowService.Update(command.borrowId, now, "Returned"); var book = await _bookRepository.Get(command.bookId); await _bookService.Update(book, book.Stock + 1); }
public async Task <IActionResult> UpdateBorrow([FromBody] BorrowDto borrow) { if (borrow == null) { return(BadRequest()); } await _borrowService.Update(borrow); return(Ok($"Borrow with id = {borrow.Id} updated.")); }
public ActionResult Return(int id) { Borrow b = bservice.Get(id); Book bk = bkservice.Get(b.Book); bk.Copy = bk.Copy + 1; bkservice.Update(bk); b.Status = 1; b.Rdate = DateTime.Now; bservice.Update(b); return(RedirectToAction("Borrowdetails")); }
public HttpResponseMessage Put([FromBody] BorrowDTO borrow) { if (borrow == null) { throw new ModelValidationResultsException(string.Format(ValidationConstants.SRequiredProperty, "borrow")); } if (borrow.BookID == 0 || borrow.StudentID == 0) { return(Request.CreateResponse(HttpStatusCode.BadRequest)); } _borrowService.Update(borrow); return(Request.CreateResponse(HttpStatusCode.OK)); }