예제 #1
0
        public ActionResult Create(PilotModel pilotModel)
        {
            try
            {
                if (!ModelState.IsValid) return PartialView(pilotModel);
                var pilotNew = PilotFactory.CreateNewPilot(pilotModel.Name, pilotModel.DebutDate.ToString(CultureInfo.InvariantCulture),
                    pilotModel.Age, pilotModel.Team);
                _pilotRepository.AddPilot(pilotNew);

                return PartialView("PilotTable", _pilotRepository.GetAllPilots());
            }
            catch (Exception ex)
            {
                Logger.AddMsgToLog(ex.Message + "\n" + ex.StackTrace);
                return View();
            }
        }
예제 #2
0
 public ActionResult Details(int id)
 {
     var pilot = _pilotRepository.GetPilot(id);
     var modelPilot = new PilotModel(pilot);
     return PartialView(modelPilot);
 }
예제 #3
0
        public ActionResult Edit(int id, PilotModel editedPilot)
        {
            try
            {
                var oldPilot = _pilotRepository.GetPilot(id);
                _pilotRepository.UpdatePilot(oldPilot, new PilotUpdateDto
                {
                    Id = id,
                    Name = editedPilot.Name,
                    Debutdate = editedPilot.DebutDate.ToString(),
                    Age = editedPilot.Age,
                    Team = editedPilot.Team
                });

                return PartialView("PilotTable", _pilotRepository.GetAllPilots());
            }
            catch (Exception ex)
            {
                Logger.AddMsgToLog(ex.Message + "\n" + ex.StackTrace);
                return View();
            }
        }
예제 #4
0
 public ActionResult Create()
 {
     var model = new PilotModel();
     return PartialView(model);
 }
예제 #5
0
        public ActionResult Edit(int id)
        {
            var oldPilot = _pilotRepository.GetPilot(id);
            var modelPilot = new PilotModel(oldPilot);

            return PartialView(modelPilot);
        }