Example #1
0
        public IActionResult AddTrain(CreatedWagon createdWagon)
        {
            int idOfNewElement = _wagons.AddWagon(createdWagon);

            if (idOfNewElement > 0)
            {
                Wagon railwayWagon = createdWagon.ToWagon();
                railwayWagon.WagonId = idOfNewElement;
                return(Created(HttpContext.Request.Scheme + "//" + HttpContext.Request.Host + HttpContext.Request.Path + "/" + idOfNewElement, railwayWagon));
            }
            else
            {
                return(NotFound("Addition didn't occure"));
            }
        }
Example #2
0
 public static Wagon ToWagon(this CreatedWagon wagon)
 {
     if (wagon != null)
     {
         return(new Wagon
         {
             WagonConfigId = wagon.WagonConfigId,
             Number = wagon.Number,
             NumberOfPlaces = wagon.NumberOfPlaces,
             TrainId = wagon.TrainId
         });
     }
     else
     {
         return(null);
     }
 }
Example #3
0
        public int AddWagon(CreatedWagon createdWagon)
        {
            Wagon wagon = createdWagon.ToWagon();

            return(_wagonRepository.Insert(wagon.ToEntity()));
        }