public void Add()
 {
     try
     {
         bool IsAdded = boatService.Add(InputBoat);
         LoadBoatList();
         if (IsAdded == true)
         {
             Message = "Added";
         }
     }
     catch (Exception e)
     {
         Console.WriteLine(e.Message);
     }
 }
Beispiel #2
0
        public ActionResult Create(PocoClasses.Entries.Boat newBoat, string returnUrl)
        {
            Mapper.Initialize(cfg => cfg.CreateMap <PocoClasses.Entries.Boat, Boat>());
            Boat boat = Mapper.Map <Boat>(newBoat);

            if (ModelState.IsValid)
            {
                using (var context = new BoatContext())
                {
                    var service = new BoatService(context);
                    service.Add(boat);
                }
                return(Redirect(returnUrl));
            }
            return(View(newBoat));
        }