public ActionResult Index(List <PersonViewModel> per) { foreach (var item in per) { service.Update(item); } return(RedirectToAction("Index")); }
public IResultadoOperaciones <Person> Update(Person Persons) { IResultadoOperaciones <Person> result = _PersonServices.Update(Persons); if (result == null) { return(BasicOperationResult <Person> .Fail(result.Message)); } return(result); }
public ActionResult Edit([Bind(Include = "Id, Birthday, Name, LastName, Email, Role")] PersonViewModel model) { try { var ps = new PersonServices(); ps.Update(model); return(RedirectToAction("Index")); } catch { return(View(model)); } }
public void RepositoryTestUpdate() { var mock = new Mock <IRepository <PDomain.Person> >(); mock.Setup(a => a.Update(persone)); mock.Setup(a => a.GetByID(persone.ID)).Returns(persone); PersonServices service = new PersonServices(mock.Object); PersonViewModel p = service.ToViewModel(persone); service.Update(p); PersonViewModel personSavedVM = service.GetById(persone.ID); PDomain.Person personSaved = service.FromViewModel(personSavedVM); Assert.AreEqual(personSavedVM.ToString(), p.ToString()); Assert.AreEqual(personSaved.ToString(), persone.ToString()); }
static void Main(string[] args) { string _input; var svc = new PersonServices <PersonModel>("PersonModel"); do { Console.WriteLine("\n!!!!!!!!!!!!!! Главное Меню !!!!!!!!!!!!!!!!!!!!!!\n"); Console.WriteLine("1. Показать всех клиентов"); Console.WriteLine("2. Показать одного клиента"); Console.WriteLine("3. Добавить Клиента"); Console.WriteLine("4. Изминить Клиента"); Console.WriteLine("5. Удалить Клиента"); _input = Console.ReadLine(); if (int.TryParse(_input, out int result)) { switch (result) { case 1: Console.WriteLine(); foreach (var _ in svc.GetRows()) { Console.WriteLine($"{_.IDNP} {_.Name} {_.LastName} {_.Age}"); } Console.ReadKey(); break; case 2: Console.WriteLine($"\nВведите IDNP / Имя или Фамилию"); _input = Console.ReadLine(); GetSearch(svc, _input); break; case 3: Console.WriteLine($"\nВведите IDNP Name LastName Age"); _input = Console.ReadLine(); var str = _input.Split(' '); try { svc.GetNew(new PersonModel() { IDNP = str[0], Name = str[1], LastName = str[2], Age = int.Parse(str[3]), }); } catch { } break; case 4: Console.WriteLine($"\n Введите IDNP / Имя или Фамилию, Клиетна которого вы хотите изминить"); _input = Console.ReadLine(); var update = GetSearch(svc, _input); Console.WriteLine($"\nВведите изминенный IDNP Name LastName Age"); _input = Console.ReadLine(); str = _input.Split(' ', ','); update.IDNP = str[0]; update.Name = str[1]; update.LastName = str[2]; update.Age = int.Parse(str[3]); Console.WriteLine($"\nУспешно обновлен"); svc.Update(update, null); break; case 5: Console.WriteLine($"\nВведите IDNP, Клиетна которого вы хотите удалить"); _input = Console.ReadLine(); var delete = GetSearch(svc, _input); svc.Delete(delete.Guid); Console.WriteLine($"\nУспешно удален"); break; default: Console.WriteLine("\nНеправельный ввод!"); break; } } } while (_input.ToUpper() != "E"); }