public JsonResult BuyHeroes(string idPlayer, string idHero) { try { var validation = _playerAppService.BuyHero(ObjectId.Parse(idPlayer), ObjectId.Parse(idHero)); if (validation.IsValid) { return(Json(new { error = "", message = validation.Message })); } return(Json(new { error = "ValidationResultError", message = validation })); } catch (Exception ex) { return(Json(new { error = "Exception", messsage = ex.Message })); } }
public HttpResponseMessage BuyHero(string idPlayer, string idHero) { try { var validation = _playerAppService.BuyHero(ObjectId.Parse(idPlayer), ObjectId.Parse(idHero)); if (validation.IsValid) { return(Request.CreateResponse(HttpStatusCode.Created, validation.ToJson())); } return(Request.CreateResponse(HttpStatusCode.BadRequest, new HttpError(validation.Erros.ToJson()))); } catch { return(Request.CreateResponse(HttpStatusCode.InternalServerError)); } }