Example #1
0
 public ActionResult Edit(string Id, IFormCollection collection)
 {
     try
     {
         int index        = Singleton.Instance.ClientsList.IndexOf(Singleton.Instance.ClientsList.Find(x => x.Id == Id));
         var ClientEdited = new Models.ClientsModel
         {
             Name        = collection["Name"],
             Lastname    = collection["LastName"],
             PhoneNumber = collection["PhoneNumber"],
             Description = collection["Description"]
         };
         Singleton.Instance.ClientsList[index] = ClientEdited;
         return(RedirectToAction(nameof(Index)));
     }
     catch
     {
         return(View());
     }
 }
Example #2
0
 public ActionResult Create(IFormCollection collection)
 {
     try
     {
         var newClient = new Models.ClientsModel
         {
             Id          = DateTime.Now.ToString().Replace("/", ""),
             Name        = collection["Name"],
             Lastname    = collection["LastName"],
             PhoneNumber = collection["PhoneNumber"],
             Description = collection["Description"]
         };
         Singleton.Instance.ClientsList.Add(newClient);
         return(RedirectToAction(nameof(Index)));
     }
     catch
     {
         return(View());
     }
 }