Exemplo n.º 1
0
 public ActionResult SubmitContact(ContactModel m)
 {
     m.Add();
     ViewBag.Message = "Su información ha sido recibida, nos comunicaremos con usted lo antes posible.";
     //ViewBag.Message = "Your information was sent successfully, we will contact you as soon as possible.";
     return(RedirectToAction("Index"));
 }
Exemplo n.º 2
0
        public async Task <IActionResult> Create([Bind("Id,FirstName,LastName,Email")] Contact contact)
        {
            if (ModelState.IsValid)
            {
                _context.Add(contact);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(contact));
        }
Exemplo n.º 3
0
        public IActionResult AddContact([Bind("Id, Nom, Prenom, Telephone")] ContactModel c, List <IFormFile> avatar)
        {
            foreach (IFormFile file in avatar)
            {
                var stream = System.IO.File.Create(@"wwwroot\images\" + file.FileName);
                file.CopyTo(stream);
            }

            string message = "";

            if (c.Id == 0)
            {
                c.Add();
                message = "contact ajouté";
            }
            else
            {
                c.Update();
                message = "contact modifié";
            }
            //TempData["message"] = "coucou";
            return(RedirectToAction("Index", new { id = message }));
        }