Ejemplo n.º 1
0
 public ActionResult AddSave(FormCollection collection)
 {
     try
     {
         string  surname  = Convert.ToString(collection["Surname"]);
         string  phone    = Convert.ToString(collection["Phone"]);
         var     contacts = phones.GetConList();
         var     maxId    = contacts.Max(p => p.Id);
         Contact contact  = new Contact()
         {
             Id = maxId + 1, Surname = surname, Phone = phone
         };
         phones.Create(contact);
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(View());
     }
 }