コード例 #1
0
        public ActionResult EditTrailer([FromForm] NewTrailerViewModel trailerData)
        {
            //trailerserveice.Updatedata
            var trailer = trailerService.GetTrailerById(trailerData.TrailerId.ToString());

            //trailer.Modify(trailer, trailerData.Model, trailerData.MaximWeightKg, trailerData.Capacity, trailerData.NumberAxles, trailerData.Height, trailerData.Width, trailerData.Length);
            trailerService.Update(trailerData.TrailerId, trailerData.Model, trailerData.MaximWeightKg, trailerData.Capacity, trailerData.NumberAxles, trailerData.Height, trailerData.Width, trailerData.Length);
            return(PartialView("_NewTrailerPartial", trailerData));
        }
コード例 #2
0
        public IActionResult EditTrailer([FromRoute] string id)
        {
            var trailer = trailerService.GetTrailerById(id);
            NewTrailerViewModel model = new NewTrailerViewModel()
            {
                TrailerId     = trailer.Id,
                Capacity      = trailer.Capacity,
                MaximWeightKg = trailer.MaximWeightKg,
                Model         = trailer.Model,
                NumberAxles   = trailer.NumberAxles,
                Height        = trailer.Height,
                Width         = trailer.Width,
                Length        = trailer.Length
            }
            ;

            return(PartialView("_NewTrailerPartial", model));
        }
コード例 #3
0
 public IActionResult NewTrailer([FromForm] NewTrailerViewModel trailerData)
 {
     try
     {
         if (ModelState.IsValid)
         {
             trailerService.CreateTrailer(trailerData.Model, trailerData.MaximWeightKg, trailerData.Capacity, trailerData.NumberAxles, trailerData.Height, trailerData.Width, trailerData.Length);
             //return RedirectToAction("Index");
         }
         return(PartialView("_NewTrailerPartial", trailerData));
     }
     catch (Exception e)
     {
         logger.LogError("Failed to create a new Trailer {@Exception}", e.Message);
         logger.LogDebug("Failed to create a new Trailer {@ExceptionMessage}", e);
         return(BadRequest(e.Message));
     }
 }