コード例 #1
0
        [HttpPost] public ActionResult AjouterBack(String id, String nom, String prenom, DateTime DateNaissance)
        {
            Client c = new Client(id, nom, prenom, DateNaissance);

            ClientsDAO.UpdateOrAddClient(c);
            return(View("Index", ClientsDAO.GetAllClients()));
        }
コード例 #2
0
        [HttpPost] public ActionResult Ajouter(Client client)//, String firstname)
        {
            //client.Prenom = firstname;
            //client.Prenom = Request.Form["firstname"]
            //client.Prenom = Request.Form.GetValues("firstname")[0];

            if (ModelState.IsValid)
            {
                ClientsDAO.UpdateOrAddClient(client);
                return(View("Index", ClientsDAO.GetAllClients()));
            }
            return(View(client));
        }
コード例 #3
0
        [HttpPost] public ActionResult Editer(Client client, String Birthday)
        {
            ModelState.Remove("Id");
            DateTime dd;

            DateTime.TryParseExact(Birthday, "dd/MM/yyyy", CultureInfo.CurrentCulture, DateTimeStyles.None, out dd);
            client.DateNaissance = dd;
            if (client.DateNaissance != null &&
                client.DateNaissance.CompareTo(DateTime.Now) > 0)
            {
                ModelState.AddModelError("DateNaissance", "Trop fort!");
            }

            if (ModelState.IsValid)
            {
                ClientsDAO.UpdateOrAddClient(client);
                return(View("Index", ClientsDAO.GetAllClients()));
            }
            return(View(client));
        }