public ActionResult Delete(DeleteContentTypeViewModel model) { // валидация модели if (ModelState.IsValid) { // удаление if (contenttype.DeleteContentType(model.contenttypes)) { // обновляем хранилище ролей RoleConfig.RepositoryRoles(); // лог logging.Logged( "Info" , "Пользователь " + User.Identity.Name + " удалил тип(ы) контента: '" + string.Join(", ", model.contenttypes.Select(x => x.Name.ToString()).ToArray()) , this.GetType().Namespace , this.GetType().Name ); return(Json(new { result = "Redirect", url = Url.Action("Index", "ContentType") })); } } ModelState.AddModelError("", "Ошибка, пожалуйста проверьте данные"); return(PartialView(model)); }
public ActionResult Delete(string json_string) { // экземпляр модели DeleteContentTypeViewModel model = new DeleteContentTypeViewModel(); // объект для десерелизации List <ContentType> contentTypes = new List <ContentType>(); // десерелизация json_string var props = json.Deserialize(json_string, contentTypes.GetType()); // наполняем contentTypes = (List <ContentType>)props; // теперь записываем в модель model.contenttypes = contentTypes; return(PartialView(model)); }