Esempio n. 1
0
        public IActionResult Add(AddTrailerViewModel addtrailerViewModel)
        {
            if (ModelState.IsValid)
            {
                Trailer newTrailer = new Trailer
                {
                    SerialNumber  = addtrailerViewModel.SerialNumber,
                    Make          = addtrailerViewModel.Make,
                    Model         = addtrailerViewModel.Model,
                    DotInsp       = addtrailerViewModel.DotInsp,
                    Plate         = addtrailerViewModel.Plate,
                    RegDate       = addtrailerViewModel.RegDate,
                    Year          = addtrailerViewModel.Year,
                    TrailerNumber = addtrailerViewModel.TrailerNumber
                };

                //add to tractorData
                context.Trailers.Add(newTrailer);
                //always save changes
                context.SaveChanges();

                return(Redirect("/Trailer"));
            }
            ;
            return(View(addtrailerViewModel));
        }
Esempio n. 2
0
        //displays form
        public IActionResult Add()
        {
            AddTrailerViewModel addtrailerViewModel = new AddTrailerViewModel();

            return(View(addtrailerViewModel));
        }