public DTOReponseObject<Play> UpdatePlay(Play updatedPlay) { if (!ValidatePlayDoesNotContainEmptyFields(updatedPlay)) { return new DTOReponseObject<Play>(HttpStatusCode.BadRequest, updatedPlay, "A show must have all fields filled, even the id"); } try { _playRepository.Update(updatedPlay); return new DTOReponseObject<Play>(HttpStatusCode.OK, null, ""); } catch (Exception e) { return new DTOReponseObject<Play>(HttpStatusCode.InternalServerError, updatedPlay, $"{e.Message}"); } }
public DTOReponseObject<Play> CreatePlay(Play play) { if (!ValidatePlayDoesNotContainEmptyFields(play)) return new DTOReponseObject<Play>(HttpStatusCode.BadRequest, play, "All fields must be filld with the exeption of Id"); else if (!DoesShowExist(play.ShowId)) return new DTOReponseObject<Play>(HttpStatusCode.BadRequest, play, "Show couldn't be found in database"); else { //try //{ _playRepository.Create(play); return new DTOReponseObject<Play>(HttpStatusCode.OK, null, ""); //} //catch(Exception e) //{ // return new DTOReponseObject<Play>(HttpStatusCode.InternalServerError, play, $"{e.Data} \n{e.Message} \nStartTime: {play.PlayStart}, EndTime: {play.PlayEnd}, location : {play.Location}, ShowId: {play.ShowId}"); //} } }
private bool ValidatePlayDoesNotContainEmptyFields(Play play) { if (play.PlayStart == null) return false; else if (play.PlayEnd == null) return false; else if (play.Location == null || play.Location == "") return false; else if (play.ShowId < 0) return false; else return true; }