Exemplo n.º 1
0
        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));
        }
Exemplo n.º 2
0
        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);
        }