本文整理汇总了C#中System.Web.Mvc.FormCollection.Remove方法的典型用法代码示例。如果您正苦于以下问题:C# FormCollection.Remove方法的具体用法?C# FormCollection.Remove怎么用?C# FormCollection.Remove使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Web.Mvc.FormCollection
的用法示例。
在下文中一共展示了FormCollection.Remove方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Index
public ActionResult Index(FormCollection formValues)
{
formValues.Remove(formValues.Keys[0]);
//get the current semester
//String semester = db.Current_Semester
String semester = "SP11";
//update the database
foreach (String key in formValues.Keys)
{
if (formValues[key].Contains("true"))
{
int class_id = Convert.ToInt32(key.Split('/')[0]);
String student_id = key.Split('/')[1];
try
{
db.Takes.First(a => a.class_id == class_id && a.student_id == student_id && a.semester_id == semester).waitlist_status = false;
}
catch { }
}
}
db.SaveChanges();
return RedirectToAction("Index");
}
示例2: Index
public ActionResult Index(FormCollection formValues)
{
formValues.Remove(formValues.Keys[0]);
//get the current semester
//String semester = db.Current_Semester
String semester = "SP11";
//update the database
foreach (String id in formValues.Keys)
{
int class_id = Convert.ToInt32(id.Split('/')[0]);
String student_id = id.Split('/')[1];
try
{
int new_grade = Convert.ToInt32(formValues[id]);
if (new_grade < 0 || new_grade > 100) { throw new Exception(); }
db.Takes.First(a => a.class_id == class_id && a.student_id == student_id && a.semester_id == semester).grade =
new_grade;
} catch { }
}
db.SaveChanges();
return RedirectToAction("Index");
}
示例3: SocketLabsEvent
public SocketLabsEvent(FormCollection formCollection)
: this()
{
ServerId = Convert.ToInt64(formCollection["ServerId"]);
Address = formCollection["Address"];
EventType type;
if (Enum.TryParse(formCollection["Type"], true, out type))
{
formCollection.Remove("Type");
}
else
{
type = EventType.Unknown;
}
Type = type;
DateTime = Convert.ToDateTime(formCollection["DateTime"]);
MailingId = formCollection["MailingId"];
MessageId = formCollection["MessageId"];
SecretKey = formCollection["SecretKey"];
formCollection.Remove("ServerId");
formCollection.Remove("Address");
formCollection.Remove("DateTime");
formCollection.Remove("MailingId");
formCollection.Remove("MessageId");
formCollection.Remove("SecretKey");
ExtraData = formCollection.AllKeys.ToDictionary(k => k, v => formCollection[v]);
}
示例4: UpdateForm
private ReportResultContext UpdateForm(FormCollection form)
{
var headerId = int.Parse(form["headerID"]);
var locationId = form["locationID"];
var pageSize = int.Parse(form["pageSize"]);
var pageIndex = int.Parse(form["pageIndex"]);
form.Remove("headerID");
form.Remove("locationID");
form.Remove("pageSize");
form.Remove("pageIndex");
return new ReportResultContext()
{
HeaderId = headerId,
LocationId = locationId,
PageIndex = pageIndex,
PageSize = pageSize
};
}
示例5: PostSurvey
public virtual string PostSurvey(FormCollection formValues, string UserId)
{
int i = 0;
string result = "";
result += "User Id of Awesomeness: " + UserId + "<br />";
formValues.Remove("UserId");
foreach (var key in formValues.AllKeys) {
result += "Index: " + i.ToString() + " Key: " + key + " Value: " + formValues[key] + ". <br />";
i++;
}
return result;
}
示例6: GetTreeData
/// <summary>
/// Check if the querystring directive of TreeQueryStringParameters.RenderParent is true, if so then
/// set the _dynamicRootNodeId value to the one being requested and only return the root node, otherwise
/// proceed as normal.
/// </summary>
/// <param name="parentId"></param>
/// <param name="queryStrings"></param>
/// <param name="actualRootNodeId"> </param>
/// <param name="nodeCollection"> </param>
/// <param name="createRootNode"> </param>
/// <param name="returnResult"> </param>
/// <param name="returnDefaultResult"> </param>
/// <returns></returns>
internal RebelTreeResult GetTreeData(
HiveId parentId,
FormCollection queryStrings,
HiveId actualRootNodeId,
TreeNodeCollection nodeCollection,
Func<FormCollection, TreeNode> createRootNode,
Func<RebelTreeResult> returnResult,
Func<HiveId, FormCollection, RebelTreeResult> returnDefaultResult)
{
if (queryStrings.GetValue<bool>(TreeQueryStringParameters.RenderParent))
{
//if the requested node does not equal the root node set, then set the _dynamicRootNodeId
if (!parentId.Value.Equals(actualRootNodeId.Value))
{
_dynamicRootNodeId = parentId;
}
//need to remove the query strings we don't want passed down to the children.
queryStrings.Remove(TreeQueryStringParameters.RenderParent);
nodeCollection.Add(createRootNode(queryStrings));
return returnResult();
}
return returnDefaultResult(parentId, queryStrings);
}
示例7: GetModelExportExcel
/// <summary>
/// Get the needed data for writing the excel file
/// </summary>
/// <param name="collection">The collection sent by the form</param>
/// <param name="businessApplicationId">Id of business application</param>
/// <param name="serviceOrderReportId">Id of service order</param>
/// <returns>DynamicDataGrid</returns>
private DynamicDataGrid GetModelExportExcel(FormCollection collection, Guid businessApplicationId, Guid serviceOrderReportId)
{
if (collection.ToFilledDictionary().Keys.Contains("InspectionReportId"))
collection.Remove("InspectionReportId");
if (collection.ToFilledDictionary().Keys.Contains("selectedInspectionReports"))
collection.Remove("selectedInspectionReports");
List<string> fielsdWithLike = new List<string>();
foreach (string name in collection.AllKeys.Where(name => name.Contains("IsLike")))
{
fielsdWithLike.Add(name.Replace("IsLike", ""));
collection.Remove(name);
}
//set the parameters for search
ParameterSearchInspectionReport parameters = new ParameterSearchInspectionReport
{
BusinessApplicationId = businessApplicationId,
Collection = collection,
InspectionReportName = _inspectionReportId,
ServiceOrderId = serviceOrderReportId,
UserName = UserName,
RolesForUser = Roles.GetRolesForUser(UserName).ToList(),
PageSize = 0,
SelectedPage = 0,
IsClient = User.IsInRole("Client"),
IsExport = true,
Captions = _captions,
FieldsWithLike = fielsdWithLike
};
//get the data
return InspectionReportBusiness.SearchInspectionReportList(parameters);
}
示例8: UnPublishInspectionReport
public PartialViewResult UnPublishInspectionReport(FormCollection collection)
{
ValueProviderResult val = collection.GetValue("inspectionReportItemId");
Guid inspectionReportItemId = new Guid(val.AttemptedValue);
collection.Remove("inspectionReportItemId");
string inspectionReportName = Session["InspectionReportName"].ToString();
InspectionReportBusiness.UnPublishInspectionReport(inspectionReportItemId, UserName, Roles.GetRolesForUser(UserName).ToList());
return SearchInspectionReport(null, inspectionReportName, collection);
}
示例9: Profile
public ActionResult Profile(FormCollection _vars)
{
var user = Membership.GetUser(Guid.Parse(_vars["UserGuid"]));
var prfMgr = new UserProfileManager(user);
UserProfileViewModel viewModel = new UserProfileViewModel() {
AccountProperties = new UserProfileManager(user).UserProfile.Properties,
UserId = (Guid)user.ProviderUserKey,
Email = user.Email,
};
user.Email = _vars["Email"];
string currPwd = _vars["CurrentPassword"];
string newPwd = _vars["NewPassword"];
string newPwdConfirmation = _vars["NewPasswordConfirmation"];
if (!string.IsNullOrWhiteSpace(currPwd)) {
// attempt to change the user's password
if (string.IsNullOrWhiteSpace(newPwd)) {
ModelState.AddModelError("NewPassword", "Você deve digitar a nova senha.");
return View(viewModel);
}
if (string.IsNullOrWhiteSpace(newPwdConfirmation)) {
ModelState.AddModelError("NewPassword", "Você deve digitar a confirmação da nova senha.");
return View(viewModel);
}
if (newPwdConfirmation != newPwd) {
ModelState.AddModelError("NewPassword", "A nova senha e a confirmação devem ser iguais.");
ModelState.AddModelError("NewPasswordConfirmation", "A nova senha e a confirmação devem ser iguais.");
return View(viewModel);
}
if (!user.ChangePassword(currPwd, newPwd)) {
ModelState.AddModelError("CurrentPassword", "Não foi possível trocar sua senha. Verifique sua senha atual e tente novamente.");
return View(viewModel);
}
}
if (_vars["Administrator"] != null) {
if (!Roles.IsUserInRole(user.UserName, "administrators")) {
Roles.AddUserToRole(user.UserName, "administrators");
}
}
else if (Roles.IsUserInRole(user.UserName, "administrators")) {
Roles.RemoveUserFromRole(user.UserName, "administrators");
}
_vars.Remove("UserGuid");
_vars.Remove("Email");
_vars.Remove("CurrentPassword");
_vars.Remove("NewPassword");
_vars.Remove("NewPasswordConfirmation");
_vars.Remove("Administrator");
foreach (string key in _vars.Keys) {
prfMgr.SetUserProfileProperty(key, _vars[key]);
}
try {
Membership.UpdateUser(user);
}
catch (ProviderException e) {
ModelState.AddModelError("Email", "Ocorreu um erro atualizar seus dados. " + e.Message);
return View(viewModel);
}
TempData["Message"] = "Dados salvos com sucesso.";
return RedirectToAction("Index", "Home");
}
示例10: ValidatePublishInspectionReports
/// <summary>
/// Delete the service Order
/// </summary>
/// <param name="collection">Service order identifier</param>
/// <returns></returns>
public PartialViewResult ValidatePublishInspectionReports(FormCollection collection)
{
ValueProviderResult val = collection.GetValue("serviceOrderId");
Guid serviceOrderId = new Guid(val.AttemptedValue);
collection.Remove("serviceOrderId");
ServiceOrderBusiness.PublishValidateAllInspectionReports(serviceOrderId, Roles.GetRolesForUser(UserName).ToList(), UserName);
return SearchOrder(null, collection);
}
示例11: Edit
public ActionResult Edit(Guid? id, Guid? userId, FormCollection collection, UserContract userContract)
{
//Save Action
//If id == null then insert
try
{
ViewData["selectedTab"] = int.Parse(collection.GetValue("selectedTab").AttemptedValue);
collection.Remove("selectedTab");
var addNewUserContract = !id.HasValue || (id == Guid.Empty);
if (ModelState.IsValid)
{
if (!addNewUserContract)
{
if (!userContract.eId.HasValue())
{
userContract.eId = Utilities.GetRandomSalt(5);
}
db.Entry(userContract).State = EntityState.Modified;
db.SaveChanges();
return BreadCrum.RedirectToPreviousAction(Session, ControllerName);
//return RedirectToAction("Edit", new { id = model.Id, userId = model.UserId });
//return View(model);
}
else
{
userContract.Id = Guid.NewGuid();
if (!userContract.eId.HasValue())
{
userContract.eId = Utilities.GetRandomSalt(5);
}
db.UserContracts.Add(userContract);
db.SaveChanges();
return BreadCrum.RedirectToPreviousAction(Session, ControllerName);
//return RedirectToAction("Edit", new { id = model.Id, userId = model.UserId });
}
}
}
catch (Exception ex)
{
//return RedirectToAction("Edit", new { id = Guid.Empty, userId = userId });
}
var user = db.Users.Find(userContract.UserId);
userContract.User = user;
return View(userContract);
//ViewBag.Contract = new SelectList(db.Contracts, "Id", "Name", userContract.Contract);
//return BreadCrum.RedirectToPreviousAction(Session, ControllerName);
}
示例12: Edit
public virtual ActionResult Edit(int id, FormCollection collection)
{
DAT_ERRORDETAIL error = _db.DAT_ERRORDETAIL.FirstOrDefault(c => c.ERRORDETAILID == id);
string lydosua = collection["LyDoSua"];
collection.Remove("LyDoSua");
if (lydosua == "")
{
ModelState.AddModelError("LyDoSua", "Chưa nhập lý do");
}
if (ModelState.IsValid)
{
try
{
// TODO: Add update logic here
// db.Entry(error).State =collection EntityState.Modified;
UpdateModel(error, collection.ToValueProvider());
string log = LogsHelper.GetRecordsForChange(_db.Entry(error));
if (error != null)
{
error.MODIDATE = DateTime.Now;
error.MODIUSER = User.Identity.Name;
error.ENTERDATE = DateTime.Now;
error.DAT_ErrorLog.Add(new DAT_ErrorLog
{
ErrorID = error.ERRORDETAILID,
ngay = DateTime.Now,
ThaoTac = "Sua",
UserId = User.Identity.Name,
DiaChi = Dns.GetHostEntry(ClientHelpers.GetClientIpAddress(Request)).HostName,
Ip = ClientHelpers.GetClientIpAddress(Request),
Logs = log,
LyDo = lydosua
});
}
_db.SaveChanges();
return RedirectToAction("Index");
}
catch
{
return View();
}
}
return View(error);
}
示例13: EditOld
public ActionResult EditOld(Guid id, Guid contractUriId, FormCollection collection)
{
//Save Action
//If id == null then insert
try
{
ViewData["selectedTab"] = int.Parse(collection.GetValue("selectedTab").AttemptedValue);
collection.Remove("selectedTab");
bool addNewUserContractRedirect = false;
if (id == Guid.Empty)
addNewUserContractRedirect = true;
if (!addNewUserContractRedirect)
{
var model = db.UserContractRedirects.FirstOrDefault(u => u.Id == id);
model.Enabled = collection.GetValue("Actief").AttemptedValue.Contains("true");
model.Name = collection.GetValue("Name").AttemptedValue;
//From Date
if (collection.GetValue("StartDatumActive").AttemptedValue.Contains("true"))
{
//We need to take the value of the date picker and store it in the model
string dpStartValue = collection.GetValue("dpStartDate").AttemptedValue;
if (!String.IsNullOrEmpty(dpStartValue) && !String.IsNullOrWhiteSpace(dpStartValue))
model.DateTimeValueStart = DataHelper.ParseDate(dpStartValue);
else
model.DateTimeValueStart = null;
}
else
model.DateTimeValueStart = null;
//To Date
if (collection.GetValue("StopDatumActive").AttemptedValue.Contains("true"))
{
string dpStopValue = collection.GetValue("dpEndDate").AttemptedValue;
if (!String.IsNullOrEmpty(dpStopValue) && !String.IsNullOrWhiteSpace(dpStopValue))
model.DateTimeValueStop = DataHelper.ParseDate(dpStopValue);
else
model.DateTimeValueStop = null;
}
else
model.DateTimeValueStop = null;
//Weekday
if (collection.GetValue("WeekdayActive").AttemptedValue.Contains("true"))
{
string weekdayValue = collection.GetValue("ddlWeekday").AttemptedValue;
if (!String.IsNullOrEmpty(weekdayValue) && !String.IsNullOrWhiteSpace(weekdayValue))
{
int day = int.Parse(weekdayValue);
if (day > 0 && day < 10)
model.DayOfTheWeekValue = day;
else
model.DayOfTheWeekValue = null;
}
}
else
model.DayOfTheWeekValue = null;
//Between from
if (collection.GetValue("BeginTimeActive").AttemptedValue.Contains("true"))
{
string tpBeginTime = collection.GetValue("tpBeginTime").AttemptedValue;
int? hour;
int? minute;
DataHelper.ParseTime(tpBeginTime, out hour, out minute);
model.TimeOfDayHourStart = hour;
model.TimeOfDayMinuteStart = minute;
}
else
model.BeginTime = null;
//Between To
if (collection.GetValue("EndTimeActive").AttemptedValue.Contains("true"))
{
string tpEndTime = collection.GetValue("tpEndTime").AttemptedValue;
int? hour;
int? minute;
DataHelper.ParseTime(tpEndTime, out hour, out minute);
model.TimeOfDayHourEnd = hour;
model.TimeOfDayMinuteEnd = minute;
}
else
model.EndTime = null;
//Counter
if (collection.GetValue("CounterActive").AttemptedValue.Contains("true"))
{
string numCounter = collection.GetValue("numCounter").AttemptedValue;
if (!String.IsNullOrEmpty(numCounter) && !String.IsNullOrWhiteSpace(numCounter))
{
int counterValue = int.Parse(numCounter);
if (counterValue > 0)
model.Counter = counterValue;
else
model.Counter = null;
}
else
model.Counter = null;
}
else
model.Counter = null;
//.........这里部分代码省略.........
示例14: Edit
public ActionResult Edit(Guid id, Guid contractUriId, UserContractRedirectModel returnModel, FormCollection collection)
{
//Save Action
//If id == null then insert
try
{
ViewData["selectedTab"] = int.Parse(collection.GetValue("selectedTab").AttemptedValue);
collection.Remove("selectedTab");
bool addNewUserContractRedirect = false;
if (id == Guid.Empty)
addNewUserContractRedirect = true;
if (!addNewUserContractRedirect)
{
var model = db.UserContractRedirects.FirstOrDefault(u => u.Id == id);
//model.Enabled = returnModel.UserContractRedirect.Enabled;
//model.Name = returnModel.UserContractRedirect.Name;
model.Enabled = returnModel.UserContractRedirect.Actief;
model.Name = returnModel.UserContractRedirect.Name;
//From Date
if (collection.GetValue("UserContractRedirect.StartDatumActive").AttemptedValue.Contains("true"))
{
//We need to take the value of the date picker and store it in the model
model.DateTimeValueStart = returnModel.UserContractRedirect.DateTimeValueStart;
}
else
model.DateTimeValueStart = null;
//To Date
if (collection.GetValue("UserContractRedirect.StopDatumActive").AttemptedValue.Contains("true"))
{
model.DateTimeValueStop = returnModel.UserContractRedirect.DateTimeValueStop;
}
else
model.DateTimeValueStop = null;
//Weekday
if (collection.GetValue("UserContractRedirect.WeekdayActive").AttemptedValue.Contains("true"))
{
string weekdayValue = collection.GetValue("ddlWeekday").AttemptedValue;
if (!String.IsNullOrEmpty(weekdayValue) && !String.IsNullOrWhiteSpace(weekdayValue))
{
int day = int.Parse(weekdayValue);
if (day > 0 && day < 10)
model.DayOfTheWeekValue = day;
else
model.DayOfTheWeekValue = null;
}
}
else
model.DayOfTheWeekValue = null;
//Between from
if (collection.GetValue("UserContractRedirect.BeginTimeActive").AttemptedValue.Contains("true"))
{
model.BeginTime = returnModel.UserContractRedirect.BeginTime;
}
else
model.BeginTime = null;
//Between To
if (collection.GetValue("UserContractRedirect.EndTimeActive").AttemptedValue.Contains("true"))
{
model.EndTime = returnModel.UserContractRedirect.EndTime;
}
else
model.EndTime = null;
//Update
var ruleValues = model.RuleParameterValues.ToList();
foreach (var ruleValue in ruleValues)
{
model.RuleParameterValues.Remove(ruleValue);
}
foreach (var parameter in returnModel.ParameterModel)
{
if (parameter.SelectedValue != null)
{
var guid = parameter.SelectedValue.Id;
var selectedValue = db.RuleParameterValues.SingleOrDefault(row => row.Id == guid);
if (selectedValue != null)
{
model.RuleParameterValues.Add(selectedValue);
}
}
}
var redirectValues = model.RedirectTypeValues.ToList();
foreach (var redirectValue in redirectValues)
{
model.RedirectTypeValues.Remove(redirectValue);
}
foreach (var redirect in returnModel.RedirectTypeModel)
{
if (redirect.SelectedValue != null)
{
var guid = redirect.SelectedValue.Id;
//.........这里部分代码省略.........
示例15: Edit
public ActionResult Edit(Guid? id, Guid? contractId, FormCollection collection, UserContractUri modelUri)
{
//Save Action
//If id == null then insert
if (!ModelState.IsValid)
{
return View(modelUri);
}
try
{
ViewData["selectedTab"] = int.Parse(collection.GetValue("selectedTab").AttemptedValue);
collection.Remove("selectedTab");
bool addNewUserContractUri = false;
if (id.HasValue)
{
if (id.Value == Guid.Empty)
addNewUserContractUri = true;
}
else
addNewUserContractUri = true;
if (!addNewUserContractUri)
{
var model = db.UserContractUris.FirstOrDefault(u => u.Id == id);
model.Enabled = modelUri.Actief;
model.Name = modelUri.Name;
model.Uri = modelUri.Uri;
model.RandomFunction = modelUri.RandomFunction;
db.SaveChanges();
return View(model);
}
else
{
UserContractUri model = new UserContractUri();
var contract = db.UserContracts.First(c => c.Id == contractId);
model.Id = Guid.NewGuid();
model.UserContractId = contract.Id;
model.Enabled = modelUri.Actief;
model.Name = modelUri.Name;
model.Uri = modelUri.Uri;
model.RandomFunction = modelUri.RandomFunction;
db.UserContractUris.Add(model);
db.SaveChanges();
//return RedirectToAction("Edit", new {id = model.Id, contractId = model.UserContractId});
//return RedirectToAction("Edit", "Contract", new { id = contract.Id, userId = contract.UserId });
return BreadCrum.RedirectToPreviousAction(Session, ControllerName);
}
}
catch(Exception ex)
{
//return RedirectToAction("Edit", new { id = Guid.Empty, contractId = contractId });
return BreadCrum.RedirectToPreviousAction(Session, ControllerName);
}
}