public async Task <IActionResult> Update([FromBody] BoardGameRent rental) { try { if (rental.IsValid()) { var original = await _db.BoardGameRent.GetById(rental.Id); original.BoardGames = rental.BoardGames; original.ReturnDate = rental.RentDate.AddDays(rental.Days); original.Days = rental.Days; original.Price = rental.Price; original.RentDate = rental.RentDate; var result = await _db.BoardGameRent.Update(original); return(Ok(result)); } else { return(BadRequest("Παρακαλώ συμπληρώστε τα υποχρεωτικά πεδία")); } } catch (Exception exc) { return(BadRequest("Σφαλμα επεξεργασίας")); } }
public async Task <IActionResult> Insert([FromBody] BoardGameRent rental) { try { if (rental.IsValid()) { rental.Created = DateTime.Now; rental.ReturnDate = rental.RentDate.AddDays(rental.Days); var result = await _db.BoardGameRent.Insert(rental); return(Ok(result)); } else { return(BadRequest("Παρακαλώ συμπληρώστε τα υποχρεωτικά πεδία")); } } catch (Exception exc) { return(BadRequest("Σφαλμα εισαγωγής")); } }