public ActionResult Create(TableCmdViewModel TableCmdViewModel)
 {
     if (!ModelState.IsValid)
     {
         return(View());
     }
     try
     {
         //TableCmd tableCmd = new TableCmd();
         //tableCmd.ID = TableCmdViewModel.ID;
         //tableCmd.Number = TableCmdViewModel.Number;
         //tableCmd.NumberOfPlace = TableCmdViewModel.NumberOfPlace;
         //tableCmd.Occupation = TableCmdViewModel.Occupation;
         //tableCmd.Place = TableCmdViewModel.Place;
         //tableCmd.ServeurId = TableCmdViewModel.ServeurId;
         var tableCmd = _mapper.Map <TableCmd>(TableCmdViewModel);
         _TableCmdRepository.Add(tableCmd);
         _TableCmdRepository.Save();
         return(RedirectToAction(nameof(Index)));
     }
     catch
     {
         return(View());
     }
 }
Example #2
0
        public ActionResult Edit(int id, TableCmdViewModel tableCmdViewModel)
        {
            if (!ModelState.IsValid)
            {
                return(View());
            }
            var exist = _tableCmdRepository.GetById(id);

            if (exist == null)
            {
                return(NotFound());
            }

            try
            {
                var tableCmd = _mappper.Map <TableCmd>(tableCmdViewModel);
                _tableCmdRepository.Update(tableCmd);
                _tableCmdRepository.Save();

                return(RedirectToAction(nameof(Index)));
            }
            catch
            {
                return(View());
            }
        }
        // GET: TableCmdController/Create
        public ActionResult Create()
        {
            TableCmdViewModel tableCmdViewModel = new TableCmdViewModel();

            tableCmdViewModel.Serveurs = _ServeurRepository.GetAll().Select(s => new SelectListItem {
                Value = s.ID.ToString(), Text = s.Name
            }).ToList();
            return(View(tableCmdViewModel));
        }
 public ActionResult Create(TableCmdViewModel tableCmds)
 {
     try
     {
         //TableCmd tbl = new TableCmd();
         //tbl.Id = tableCmds.Id;
         //tbl.Numero = tableCmds.Numero;
         //tbl.NbPlace = tableCmds.NbPlace;
         //tbl.Occupation = tableCmds.Occupation;
         //tbl.Emplacement = tableCmds.Emplacement;
         //tbl.ServeurId = tableCmds.ServeurId;
         var tbl = _mapper.Map <TableCmd>(tableCmds);
         _tableCmdRepository.Insert(tbl);
         _tableCmdRepository.Save();
         return(RedirectToAction(nameof(Index)));
     }
     catch
     {
         return(View());
     }
 }