public IActionResult AddTrain(CreatedTrain createdTrain) { int idOfNewElement = _train.AddTrain(createdTrain); Train train = createdTrain.ToTrain(); train.TrainId = idOfNewElement; return(Created(HttpContext.Request.Scheme + "//" + HttpContext.Request.Host + HttpContext.Request.Path + "/" + idOfNewElement, train)); }
public decimal TrainHero(Train train) { train.TrainDate = DateTime.Now; var addTrainRes = _trainService.AddTrain(train); if (addTrainRes) { return(_heroService.UpdatePower(train.HeroId)); } throw new WebApiException(405, "error in add train for hero " + train.HeroId); }