Working on validation for forms, issues with server side, not sure how to post back model with AJAX submit, yet.

Split out settings model to support validation.
This commit is contained in:
markus101 2011-02-10 17:22:29 -08:00
parent 6690139616
commit 6e66a7a27f
11 changed files with 381 additions and 206 deletions

View File

@ -142,6 +142,7 @@
<HintPath>D:\OpenSource\sabscripts\SABSync\References\SubSonic.Core.dll</HintPath> <HintPath>D:\OpenSource\sabscripts\SABSync\References\SubSonic.Core.dll</HintPath>
</Reference> </Reference>
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.ComponentModel.DataAnnotations" />
<Reference Include="System.configuration" /> <Reference Include="System.configuration" />
<Reference Include="System.Core" /> <Reference Include="System.Core" />
<Reference Include="System.Data" /> <Reference Include="System.Data" />

View File

@ -1,6 +1,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel; using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using SubSonic.SqlGeneration.Schema; using SubSonic.SqlGeneration.Schema;
namespace NzbDrone.Core.Repository.Quality namespace NzbDrone.Core.Repository.Quality
@ -23,6 +24,7 @@ namespace NzbDrone.Core.Repository.Quality
public string AllowedString { get; set; } public string AllowedString { get; set; }
[DisplayName("Cutoff")] [DisplayName("Cutoff")]
[Required(ErrorMessage = "Valid Cutoff is Required")]
public QualityTypes Cutoff { get; set; } public QualityTypes Cutoff { get; set; }
[EditorBrowsable(EditorBrowsableState.Never)] [EditorBrowsable(EditorBrowsableState.Never)]

View File

@ -5,6 +5,7 @@ using System.Threading;
using System.Web; using System.Web;
using System.Web.Mvc; using System.Web.Mvc;
using NLog; using NLog;
using NzbDrone.Core.Model;
using NzbDrone.Core.Providers; using NzbDrone.Core.Providers;
using NzbDrone.Core.Repository.Quality; using NzbDrone.Core.Repository.Quality;
using NzbDrone.Web.Models; using NzbDrone.Web.Models;
@ -53,7 +54,7 @@ namespace NzbDrone.Web.Controllers
public ActionResult Indexers() public ActionResult Indexers()
{ {
ViewData["viewName"] = "Indexers"; ViewData["viewName"] = "Indexers";
return View("Index", new SettingsModel return View("Index", new IndexerSettingsModel
{ {
NzbMatrixUsername = _configProvider.GetValue("NzbMatrixUsername", String.Empty, false), NzbMatrixUsername = _configProvider.GetValue("NzbMatrixUsername", String.Empty, false),
NzbMatrixApiKey = _configProvider.GetValue("NzbMatrixApiKey", String.Empty, false), NzbMatrixApiKey = _configProvider.GetValue("NzbMatrixApiKey", String.Empty, false),
@ -68,30 +69,22 @@ namespace NzbDrone.Web.Controllers
public ActionResult Downloads() public ActionResult Downloads()
{ {
ViewData["viewName"] = "Downloads"; ViewData["viewName"] = "Downloads";
return View("Index", new SettingsModel
{
//Sync Frequency
//Download Propers?
//Retention
//SAB Host/IP
//SAB Port
//SAB APIKey
//SAB Username
//SAB Password
//SAB Category
//SAB Priority
SyncFrequency = Convert.ToInt32(_configProvider.GetValue("SyncFrequency", "15", true)), var model = new DownloadSettingsModel
DownloadPropers = Convert.ToBoolean(_configProvider.GetValue("DownloadPropers", "false", true)), {
Retention = Convert.ToInt32(_configProvider.GetValue("Retention", "500", true)), SyncFrequency = Convert.ToInt32(_configProvider.GetValue("SyncFrequency", "15", true)),
SabHost = _configProvider.GetValue("SabHost", "localhost", false), DownloadPropers = Convert.ToBoolean(_configProvider.GetValue("DownloadPropers", "false", true)),
SabPort = Convert.ToInt32(_configProvider.GetValue("SabPort", "8080", true)), Retention = Convert.ToInt32(_configProvider.GetValue("Retention", "500", true)),
SabApiKey = _configProvider.GetValue("SabApiKey", String.Empty, false), SabHost = _configProvider.GetValue("SabHost", "localhost", false),
SabUsername = _configProvider.GetValue("SabUsername", String.Empty, false), SabPort = Convert.ToInt32(_configProvider.GetValue("SabPort", "8080", true)),
SabPassword = _configProvider.GetValue("SabPassword", String.Empty, false), SabApiKey = _configProvider.GetValue("SabApiKey", String.Empty, false),
SabCategory = _configProvider.GetValue("SabCategory", String.Empty, false), SabUsername = _configProvider.GetValue("SabUsername", String.Empty, false),
//SabPriority = _configProvider.GetValue("SabPriority", String.Empty, false) SabPassword = _configProvider.GetValue("SabPassword", String.Empty, false),
}); SabCategory = _configProvider.GetValue("SabCategory", String.Empty, false),
SabPriority = (SabnzbdPriorityType)Enum.Parse(typeof(SabnzbdPriorityType), _configProvider.GetValue("SabPriority", "Normal", true)),
};
return View("Index", model);
} }
public ActionResult Quality() public ActionResult Quality()
@ -109,7 +102,7 @@ namespace NzbDrone.Web.Controllers
var userProfiles = _qualityProvider.GetAllProfiles().Where(q => q.UserProfile).ToList(); var userProfiles = _qualityProvider.GetAllProfiles().Where(q => q.UserProfile).ToList();
var profiles = _qualityProvider.GetAllProfiles().ToList(); var profiles = _qualityProvider.GetAllProfiles().ToList();
var defaultQualityProfileId = Convert.ToInt32(_configProvider.GetValue("DefaultQualityProfile", profiles[0].ProfileId, true)); var defaultQualityProfileId = Convert.ToInt32(_configProvider.GetValue("DefaultQualityProfile", profiles[0].ProfileId, true));
var selectList = new SelectList(profiles, "ProfileId", "Name"); var selectList = new SelectList(profiles, "ProfileId", "Name");
@ -150,10 +143,6 @@ namespace NzbDrone.Web.Controllers
try try
{ {
_configProvider.SeriesRoot = data.TvFolder; _configProvider.SeriesRoot = data.TvFolder;
_configProvider.SetValue("NzbMatrixUsername", data.NzbMatrixUsername);
_configProvider.SetValue("NzbMatrixApiKey", data.NzbMatrixApiKey);
_configProvider.SetValue("NzbsOrgUId", data.NzbsOrgUId);
_configProvider.SetValue("NzbsOrgHash", data.NzbsOrgHash);
} }
catch (Exception) catch (Exception)
{ {
@ -191,7 +180,7 @@ namespace NzbDrone.Web.Controllers
return Content("Error Saving Settings, please fix any errors"); return Content("Error Saving Settings, please fix any errors");
} }
if (Request.IsAjaxRequest()) if (Request.IsAjaxRequest())
return Content("Settings Saved."); return Content("Settings Saved.");
@ -199,7 +188,7 @@ namespace NzbDrone.Web.Controllers
} }
[HttpPost] [HttpPost]
public ActionResult SaveIndexers(SettingsModel data) public ActionResult SaveIndexers(IndexerSettingsModel data)
{ {
try try
{ {
@ -245,52 +234,59 @@ namespace NzbDrone.Web.Controllers
} }
[HttpPost] [HttpPost]
public ActionResult SaveDownloads(SettingsModel data) public ActionResult SaveDownloads(DownloadSettingsModel data)
{ {
try if (ModelState.IsValid)
{ {
if (data.SyncFrequency > 15) try
_configProvider.SetValue("SyncFrequency", data.SyncFrequency.ToString()); {
if (data.SyncFrequency > 15)
_configProvider.SetValue("SyncFrequency", data.SyncFrequency.ToString());
_configProvider.SetValue("DownloadPropers", data.DownloadPropers.ToString()); _configProvider.SetValue("DownloadPropers", data.DownloadPropers.ToString());
if (data.Retention > 0) if (data.Retention > 0)
_configProvider.SetValue("Retention", data.Retention.ToString()); _configProvider.SetValue("Retention", data.Retention.ToString());
if (data.SabHost != null) if (data.SabHost != null)
_configProvider.SetValue("SabHost", data.SabHost); _configProvider.SetValue("SabHost", data.SabHost);
if (data.SabPort > 0) if (data.SabPort > 0)
_configProvider.SetValue("SabPort", data.SabPort.ToString()); _configProvider.SetValue("SabPort", data.SabPort.ToString());
if (data.SabApiKey != null) if (data.SabApiKey != null)
_configProvider.SetValue("SabApiKey", data.SabApiKey); _configProvider.SetValue("SabApiKey", data.SabApiKey);
if (data.SabUsername != null) if (data.SabUsername != null)
_configProvider.SetValue("SabUsername", data.SabUsername); _configProvider.SetValue("SabUsername", data.SabUsername);
if (data.SabPassword != null) if (data.SabPassword != null)
_configProvider.SetValue("SabPassword", data.SabPassword); _configProvider.SetValue("SabPassword", data.SabPassword);
if (data.SabCategory != null) if (data.SabCategory != null)
_configProvider.SetValue("SabCategory", data.SabCategory); _configProvider.SetValue("SabCategory", data.SabCategory);
_configProvider.SetValue("SabPriority", data.SabPriority.ToString());
if (Request.IsAjaxRequest())
return Content("Settings Saved.");
return Content("Settings Saved.");
}
catch (Exception e)
{
Logger.ErrorException(e.Message, e);
if (Request.IsAjaxRequest())
return Content("Error Saving Settings, please fix any errors");
//if (data.SabPriority != null)
// _configProvider.SetValue("SabPriority", data.SabPriority.ToString());
}
catch (Exception e)
{
Logger.ErrorException(e.Message, e);
if (Request.IsAjaxRequest())
return Content("Error Saving Settings, please fix any errors"); return Content("Error Saving Settings, please fix any errors");
}
return Content("Error Saving Settings, please fix any errors");
} }
if (Request.IsAjaxRequest()) //ViewData["viewName"] = "Downloads";
return Content("Settings Saved."); //return View("Index", data);
return Content("Error Saving Settings, please fix any errors");
return Content("Settings Saved.");
} }
[HttpPost] [HttpPost]
@ -314,14 +310,14 @@ namespace NzbDrone.Web.Controllers
profile.Allowed = new List<QualityTypes>(); profile.Allowed = new List<QualityTypes>();
foreach (var quality in profile.AllowedString.Split(',')) foreach (var quality in profile.AllowedString.Split(','))
{ {
var qType = (QualityTypes)Enum.Parse(typeof (QualityTypes), quality); var qType = (QualityTypes)Enum.Parse(typeof(QualityTypes), quality);
profile.Allowed.Add(qType); profile.Allowed.Add(qType);
} }
//If the Cutoff value selected is not in the allowed list then use the last allowed value, this should be validated on submit //If the Cutoff value selected is not in the allowed list then use the last allowed value, this should be validated on submit
if (!profile.Allowed.Contains(profile.Cutoff)) if (!profile.Allowed.Contains(profile.Cutoff))
throw new InvalidOperationException("Invalid Cutoff Value"); throw new InvalidOperationException("Invalid Cutoff Value");
//profile.Cutoff = profile.Allowed.Last(); //profile.Cutoff = profile.Allowed.Last();
if (profile.ProfileId > 0) if (profile.ProfileId > 0)
_qualityProvider.Update(profile); _qualityProvider.Update(profile);
@ -334,6 +330,7 @@ namespace NzbDrone.Web.Controllers
catch (Exception e) catch (Exception e)
{ {
Logger.ErrorException(e.Message, e); Logger.ErrorException(e.Message, e);
if (Request.IsAjaxRequest()) if (Request.IsAjaxRequest())
return Content("Error Saving Settings, please fix any errors"); return Content("Error Saving Settings, please fix any errors");
@ -347,9 +344,9 @@ namespace NzbDrone.Web.Controllers
} }
[HttpPost] [HttpPost]
public ActionResult SortedList(List<object > items) public ActionResult SortedList(List<object> items)
{ {
return Content("Settings Saved."); return Content("Settings Saved.");
} }
} }
} }

View File

@ -0,0 +1,101 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using NzbDrone.Core.Model;
namespace NzbDrone.Web.Models
{
public class DownloadSettingsModel
{
[Required]
[Range(15, 120, ErrorMessage = "Must be between 15 and 120 minutes")]
[DataType(DataType.Text)]
[DisplayName("Sync Frequency")]
public int SyncFrequency
{
get;
set;
}
[DisplayName("Download Propers")]
public bool DownloadPropers
{
get;
set;
}
[Required (ErrorMessage = "Please enter a valid number")]
[DataType(DataType.Text)]
[DisplayName("Retention")]
public int Retention
{
get;
set;
}
[Required (ErrorMessage = "Please enter a valid host")]
[DataType(DataType.Text)]
[DisplayName("SABnzbd Host")]
public String SabHost
{
get;
set;
}
[Required(ErrorMessage = "Please enter a valid port")]
[DataType(DataType.Text)]
[DisplayName("SABnzbd Port")]
public int SabPort
{
get;
set;
}
[DataType(DataType.Text)]
[DisplayName("SABnzbd API Key")]
public String SabApiKey
{
get;
set;
}
[DataType(DataType.Text)]
[DisplayName("SABnzbd Username")]
public String SabUsername
{
get;
set;
}
[DataType(DataType.Text)]
[DisplayName("SABnzbd Password")]
public String SabPassword
{
get;
set;
}
[DataType(DataType.Text)]
[DisplayName("SABnzbd Category")]
public String SabCategory
{
get;
set;
}
[Required(ErrorMessage = "Please select a valid priority")]
[DataType(DataType.Text)]
[DisplayName("SABnzbd Priority")]
public SabnzbdPriorityType SabPriority
{
get;
set;
}
public SelectList PrioritySelectList = new SelectList(new string[] { "Low", "Normal", "High" });
}
}

View File

@ -0,0 +1,67 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Web;
using NzbDrone.Core.Repository;
namespace NzbDrone.Web.Models
{
public class IndexerSettingsModel
{
[DataType(DataType.Text)]
[DisplayName("NZBMatrix Username")]
public String NzbMatrixUsername
{
get;
set;
}
[DataType(DataType.Text)]
[DisplayName("NZBMatrix API Key")]
public String NzbMatrixApiKey
{
get;
set;
}
[DataType(DataType.Text)]
[DisplayName("NZBs.Org UID")]
public String NzbsOrgUId
{
get;
set;
}
[DataType(DataType.Text)]
[DisplayName("NZBs.Org Hash")]
public String NzbsOrgHash
{
get;
set;
}
[DataType(DataType.Text)]
[DisplayName("NZBsRus UID")]
public String NzbsrusUId
{
get;
set;
}
[DataType(DataType.Text)]
[DisplayName("NZBsRus Hash")]
public String NzbsrusHash
{
get;
set;
}
public List<Indexer> Indexers
{
get;
set;
}
}
}

View File

@ -1,6 +1,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel; using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Linq; using System.Linq;
using System.Web; using System.Web;
using System.Web.Mvc; using System.Web.Mvc;

View File

@ -30,156 +30,156 @@ namespace NzbDrone.Web.Models
#endregion #endregion
#region Indexer Settings //#region Indexer Settings
[DataType(DataType.Text)] //[DataType(DataType.Text)]
[DisplayName("NZBMatrix Username")] //[DisplayName("NZBMatrix Username")]
public String NzbMatrixUsername //public String NzbMatrixUsername
{ //{
get; // get;
set; // set;
} //}
[DataType(DataType.Text)] //[DataType(DataType.Text)]
[DisplayName("NZBMatrix API Key")] //[DisplayName("NZBMatrix API Key")]
public String NzbMatrixApiKey //public String NzbMatrixApiKey
{ //{
get; // get;
set; // set;
} //}
[DataType(DataType.Text)] //[DataType(DataType.Text)]
[DisplayName("NZBs.Org UID")] //[DisplayName("NZBs.Org UID")]
public String NzbsOrgUId //public String NzbsOrgUId
{ //{
get; // get;
set; // set;
} //}
[DataType(DataType.Text)] //[DataType(DataType.Text)]
[DisplayName("NZBs.Org Hash")] //[DisplayName("NZBs.Org Hash")]
public String NzbsOrgHash //public String NzbsOrgHash
{ //{
get; // get;
set; // set;
} //}
[DataType(DataType.Text)] //[DataType(DataType.Text)]
[DisplayName("NZBsRus UID")] //[DisplayName("NZBsRus UID")]
public String NzbsrusUId //public String NzbsrusUId
{ //{
get; // get;
set; // set;
} //}
[DataType(DataType.Text)] //[DataType(DataType.Text)]
[DisplayName("NZBsRus Hash")] //[DisplayName("NZBsRus Hash")]
public String NzbsrusHash //public String NzbsrusHash
{ //{
get; // get;
set; // set;
} //}
public List<Indexer> Indexers //public List<Indexer> Indexers
{ //{
get; // get;
set; // set;
} //}
#endregion //#endregion
#region Download Settings //#region Download Settings
//Sync Frequency ////Sync Frequency
//Download Propers? ////Download Propers?
//Retention ////Retention
//SAB Host/IP ////SAB Host/IP
//SAB Port ////SAB Port
//SAB APIKey ////SAB APIKey
//SAB Username ////SAB Username
//SAB Password ////SAB Password
//SAB Category ////SAB Category
//SAB Priority ////SAB Priority
[DataType(DataType.Text)] //[DataType(DataType.Text)]
[DisplayName("Sync Frequency")] //[DisplayName("Sync Frequency")]
public int SyncFrequency //public int SyncFrequency
{ //{
get; // get;
set; // set;
} //}
[DisplayName("Download Propers")] //[DisplayName("Download Propers")]
public bool DownloadPropers //public bool DownloadPropers
{ //{
get; // get;
set; // set;
} //}
[DataType(DataType.Text)] //[DataType(DataType.Text)]
[DisplayName("Retention")] //[DisplayName("Retention")]
public int Retention //public int Retention
{ //{
get; // get;
set; // set;
} //}
[DataType(DataType.Text)] //[DataType(DataType.Text)]
[DisplayName("SABnzbd Host")] //[DisplayName("SABnzbd Host")]
public String SabHost //public String SabHost
{ //{
get; // get;
set; // set;
} //}
[DataType(DataType.Text)] //[DataType(DataType.Text)]
[DisplayName("SABnzbd Port")] //[DisplayName("SABnzbd Port")]
public int SabPort //public int SabPort
{ //{
get; // get;
set; // set;
} //}
[DataType(DataType.Text)] //[DataType(DataType.Text)]
[DisplayName("SABnzbd API Key")] //[DisplayName("SABnzbd API Key")]
public String SabApiKey //public String SabApiKey
{ //{
get; // get;
set; // set;
} //}
[DataType(DataType.Text)] //[DataType(DataType.Text)]
[DisplayName("SABnzbd Username")] //[DisplayName("SABnzbd Username")]
public String SabUsername //public String SabUsername
{ //{
get; // get;
set; // set;
} //}
[DataType(DataType.Text)] //[DataType(DataType.Text)]
[DisplayName("SABnzbd Password")] //[DisplayName("SABnzbd Password")]
public String SabPassword //public String SabPassword
{ //{
get; // get;
set; // set;
} //}
[DataType(DataType.Text)] //[DataType(DataType.Text)]
[DisplayName("SABnzbd Category")] //[DisplayName("SABnzbd Category")]
public String SabCategory //public String SabCategory
{ //{
get; // get;
set; // set;
} //}
[DataType(DataType.Text)] //[DataType(DataType.Text)]
[DisplayName("SABnzbd Priority")] //[DisplayName("SABnzbd Priority")]
public SabnzbdPriorityType SabPriority //public SabnzbdPriorityType SabPriority
{ //{
get; // get;
set; // set;
} //}
#endregion //#endregion
} }
} }

View File

@ -85,6 +85,8 @@
<Compile Include="Helpers\HtmlPrefixScopeExtensions.cs" /> <Compile Include="Helpers\HtmlPrefixScopeExtensions.cs" />
<Compile Include="Helpers\IsCurrentActionHelper.cs" /> <Compile Include="Helpers\IsCurrentActionHelper.cs" />
<Compile Include="Models\AccountModels.cs" /> <Compile Include="Models\AccountModels.cs" />
<Compile Include="Models\DownloadSettingsModel.cs" />
<Compile Include="Models\IndexerSettingsModel.cs" />
<Compile Include="Models\MappingModel.cs" /> <Compile Include="Models\MappingModel.cs" />
<Compile Include="Models\EpisodeModel.cs" /> <Compile Include="Models\EpisodeModel.cs" />
<Compile Include="Models\QualityModel.cs" /> <Compile Include="Models\QualityModel.cs" />

View File

@ -1,4 +1,4 @@
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<NzbDrone.Web.Models.SettingsModel>" %> <%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<NzbDrone.Web.Models.DownloadSettingsModel>" %>
<script type="text/javascript"> <script type="text/javascript">
$(document).ready(function () { $(document).ready(function () {
@ -23,6 +23,10 @@
} }
</script> </script>
<script src="/Scripts/MicrosoftAjax.js" type="text/javascript"></script>
<script src="/Scripts/MicrosoftMvcValidation.js" type="text/javascript"></script>
<% Html.EnableClientValidation(); %>
<% using (Html.BeginForm("SaveDownloads", "Settings", FormMethod.Post, new { id = "form", name = "form" })) <% using (Html.BeginForm("SaveDownloads", "Settings", FormMethod.Post, new { id = "form", name = "form" }))
{%> {%>
<%: Html.ValidationSummary(true, "Unable to save your settings. Please correct the errors and try again.") %> <%: Html.ValidationSummary(true, "Unable to save your settings. Please correct the errors and try again.") %>
@ -103,13 +107,11 @@
<div class="config-validation"><%= Html.ValidationMessageFor(m => m.SabCategory)%></div> <div class="config-validation"><%= Html.ValidationMessageFor(m => m.SabCategory)%></div>
</div> </div>
<%--<div class="editor-label"> <div class="config-group">
<%= Html.DropDownListFor(m => m.SabPriority) %> <div class="config-title"><%= Html.LabelFor(m => m.SabPriority) %></div>
<div class="config-value"><%= Html.DropDownListFor(m => m.SabPriority, Model.PrioritySelectList) %></div>
<div class="config-validation"><%= Html.ValidationMessageFor(m => m.SabCategory)%></div>
</div> </div>
<div class="editor-field">
<%= Html.TextBoxFor(m => m.SabCategory)%>
<%= Html.ValidationMessageFor(m => m.SabCategory)%>
</div>--%>
</fieldset> </fieldset>
<p> <p>

View File

@ -1,4 +1,4 @@
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<NzbDrone.Web.Models.SettingsModel>" %> <%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<NzbDrone.Web.Models.IndexerSettingsModel>" %>
<script type="text/javascript"> <script type="text/javascript">
$(document).ready(function () { $(document).ready(function () {

View File

@ -89,13 +89,15 @@
<li class="ui-state-default" id="<%= qualitiesList[i].ToString() %>"> <li class="ui-state-default" id="<%= qualitiesList[i].ToString() %>">
<%=Html.RadioButtonFor(x => x.Cutoff, qualitiesList[i])%> <%=Html.RadioButtonFor(x => x.Cutoff, qualitiesList[i])%>
<%= Html.Label(qualitiesList[i].ToString()) %> <%= Html.Label(qualitiesList[i].ToString()) %>
<%--<%= Html.RenderPartial("ProfileAllowedQualities", Model.Allowed[i]) %>--%>
</li> </li>
<% } %> <% } %>
</ul> </ul>
</div> </div>
</div> </div>
<%= Html.ValidationMessageFor(x => x.Cutoff) %>
<div class="hiddenProfileDetails"> <div class="hiddenProfileDetails">
<%= Html.TextBoxFor(x => x.ProfileId, new { @style = "display:none" })%> <%= Html.TextBoxFor(x => x.ProfileId, new { @style = "display:none" })%>
<%= Html.CheckBoxFor(x => x.UserProfile, new { @style = "display:none" })%> <%= Html.CheckBoxFor(x => x.UserProfile, new { @style = "display:none" })%>