public async Task <IHttpActionResult> AddDemand(Demand demand) { try { _DemandRepository = new DemandRepository(); await _DemandRepository.AddDemand(demand); return(Ok()); } catch (Exception e) { return(BadRequest("Error: " + e.Message)); } }
public async Task <IHttpActionResult> GetBookById(string id) { try { _BookRepository = new BookRepository(); _DemandRepository = new DemandRepository(); Book book = await _BookRepository.GetBookById(id); User user = await this.AppUserManager.FindByNameAsync(User.Identity.Name); if (await _DemandRepository.CheckDemandExist(user, book) == null) { await _DemandRepository.AddDemand(new Demand() { Book = book, User = user }); } return(Ok(book)); } catch (Exception e) { return(BadRequest("Error: " + e.Message)); } }