//Edit box with a specified BoxModel public ActionResult Edit(BoxModel viewModel) { if (ModelState.IsValid) { BoxDTO @new = new BoxDTO(); foreach (PropertyInfo property in @new.GetType().GetProperties()) { property.SetValue(@new, viewModel.GetType().GetProperty(property.Name).GetValue(viewModel)); } _service.Edit(@new); return(RedirectToAction("List")); } else { return(RedirectToAction("Edit", new { id = viewModel.ID })); } }