本文整理汇总了C#中System.Web.Mvc.FormCollection.GetValue方法的典型用法代码示例。如果您正苦于以下问题:C# FormCollection.GetValue方法的具体用法?C# FormCollection.GetValue怎么用?C# FormCollection.GetValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Web.Mvc.FormCollection
的用法示例。
在下文中一共展示了FormCollection.GetValue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Create
public ActionResult Create(FormCollection form)
{
var chapters = form.AllKeys.Where(s => s.Contains("section"));
var numChapters = chapters.Count();
string bookName = form.GetValue("bookName").AttemptedValue;
var book = new Book { BookID = bookName, AgeGroup = (AgeGroups)Enum.Parse(typeof(AgeGroups), form.GetValue("ageGroup").AttemptedValue, true) };
db.Books.Add(book);
var counter = 1;
foreach (var chapter in chapters)
{
var dbChapter = new Chapter { BookID = book.BookID, ChapterID = counter++ };
db.Chapters.Add(dbChapter);
int numSections = int.Parse(form.GetValue(chapter).AttemptedValue);
for (int i = 0; i < numSections; i++)
{
db.Sections.Add(new Section { ChapterID = dbChapter.ChapterID, BookID = dbChapter.BookID, SectionID = i + 1 });
}
}
db.SaveChanges();
return RedirectToAction("Index");
}
示例2: Progress
public JsonResult Progress(FormCollection Fm)
{
//todo 通过cookie获得用户关联到项目
//todo 根据后台可编辑时间确定是否接收
var _sequence = int.Parse(Fm.GetValue("sequence").AttemptedValue);
var _title = Fm.GetValue("title").AttemptedValue;
var _content = Fm.GetValue("content").AttemptedValue;
DBHelper.instence.Project_progress.AddOrUpdate(new Project_Progress { sequence = _sequence, title = _title, content = _content });
if(DBHelper.instence.SaveChanges()>0)
return new JsonResult
{
Data = new
{
message = "项目第"+ _sequence + "次记录保存成功!"
}
};
else
return new JsonResult
{
Data = new
{
message = "提交失败!"
}
};
}
示例3: Edit
public ActionResult Edit(int id, FormCollection forms)
{
if (id == 0)
{
CmsMenu newMenu = new CmsMenu()
{
Title = forms.GetValue("Title").AttemptedValue,
Description = forms.GetValue("Description").AttemptedValue,
Type = forms.GetValue("Type").AttemptedValue
};
if (newMenu.IsValid)
{
return this.CreateNewMenu(newMenu);
}
ModelState.AddModelErrors(newMenu.GetRuleViolations());
return View(newMenu);
}
CmsMenu menu = this.menuService.LoadMenu(id);
UpdateModel(menu, forms.ToValueProvider());
this.menuService.SaveMenu(menu);
TempData["SuccessResult"] = "Menu was successfully saved";
return this.View(menu);
}
示例4: Create
public ActionResult Create(FormCollection collection)
{
try
{
NHibernateHelper nhibernateHelper = new NHibernateHelper(@"fluentData.db");
using(ISessionFactory sessionFactory = nhibernateHelper.GetSessionFactory())
{
using (ISession session = sessionFactory.OpenSession())
{
using (ITransaction transaction = session.BeginTransaction())
{
var company = new Company
{
OrganizationNumber = collection.GetValue("OrganizationNumber").AttemptedValue,
Name = collection.GetValue("Name").AttemptedValue
};
session.SaveOrUpdate(company);
transaction.Commit();
//collection.Set("Id", company.Id.ToString());
return RedirectToAction("Edit", new { id = company.Id });
}
}
}
}
catch
{
return View();
}
}
示例5: TransactionsFilter
public TransactionsFilter(FormCollection formCollection)
{
Years = int.Parse(GetValue(formCollection.GetValue("Years")));
Months = int.Parse(GetValue(formCollection.GetValue("Months")));
PaymentMethods = GetValue(formCollection.GetValue(PAYMENT_METHODS_ID));
InitPaymentMethodsList(GetValue(formCollection.GetValue(PAYMENT_METHODS_ID)));
}
示例6: AdditionalDetails
public ActionResult AdditionalDetails(FormCollection form)
{
EnquiryDetails details = new EnquiryDetails();
details.Amount = Convert.ToDouble(form.GetValue("amount").AttemptedValue);
details.FileName = form.GetValue("uploadpath").AttemptedValue.ToString();
details.UniqueName = form.GetValue("savedName").AttemptedValue.ToString();
details.EnquiryID = Convert.ToInt32(TempData["EnquiryId"]);
enquiryDetailsRepository.InsertOrUpdate(details);
enquiryDetailsRepository.Save();
return RedirectToAction("Details", new { id = details.EnquiryID });
}
示例7: Index
public ActionResult Index(FormCollection collection)
{
DateTime startDate = Convert.ToDateTime(collection.GetValue("todate").AttemptedValue).Date;
DateTime endDate = Convert.ToDateTime(collection.GetValue("fromdate").AttemptedValue).Date;
JiraPresenter jiraPresenter = new JiraPresenter();
List<JiraTimeSheet> jiraTimeSheetList = jiraPresenter.ProcessIssues(startDate, endDate);
ViewBag.startdate = startDate;
ViewBag.enddate = endDate;
ViewBag.title = "Displaying " + jiraTimeSheetList.Count + " issues at " + DateTime.Now + " from "+ startDate.Date + " to " + endDate.Date;
return View("WorkLogs", jiraTimeSheetList);
}
示例8: Create
public ActionResult Create(FormCollection collection)
{
_repository.AddMovie(collection.GetValue("Title").ToString(), collection.GetValue("Genre").ToString());
try
{
// TODO: Add insert logic here
return RedirectToAction("Index");
}
catch
{
return View();
}
}
示例9: AdminDeviceSearch
public ActionResult AdminDeviceSearch(FormCollection collection)
{
#region Get Search Query
string query = collection.GetValue("query").AttemptedValue;
#endregion
#region Prep Utilities
BusinessLogicHandler myHandler = new BusinessLogicHandler();
SearchViewModel model = new SearchViewModel();
#endregion
#region Execute Search
model.Query = query;
model.GadgetResults = myHandler.TechnologyGlobalSearch(query);
model.GadgetCategoryResults = myHandler.DeviceGlobalSearch(query);
model.ManufacturerResults = myHandler.ManufacturerGlobalSearch(query);
#endregion
return View(model);
}
示例10: AddApplicationSubscription
public ActionResult AddApplicationSubscription(Subscription record, FormCollection form)
{
try
{
record.Type = "Application";
record.CreatedDate = DateTime.Now;
record.State = "Active";
var application_ = form.GetValue("application_");
if ((application_ != null) && (application_.AttemptedValue != null))
{
int applicationId = Int32.Parse(application_.AttemptedValue);
SubscriptionItem item = new SubscriptionItem();
item.ApplicationId = applicationId;
record.Items = new List<SubscriptionItem>();
record.Items.Add(item);
}
CcAddSubscriptionRequest request = new CcAddSubscriptionRequest(Settings.Credentials);
request.Subscription = record;
EndPoints.CcDashboardService.AddSubscription(request);
return RedirectToAction("Subscriptions");
}
catch (Exception e)
{
return ShowError(e);
}
}
示例11: AdminBookSearch
public ActionResult AdminBookSearch(FormCollection collection)
{
#region Get Search Query
string query = collection.GetValue("query").AttemptedValue;
#endregion
#region Prep Utilities
BusinessLogicHandler myHandler = new BusinessLogicHandler();
SearchViewModel model = new SearchViewModel();
#endregion
#region Execute Search
model.Query = query;
model.BookResults = myHandler.BookGlobalSearch(query);
model.BookCategoryResults = myHandler.BookCategoryGlobalSearch(query);
model.AuthorResults = myHandler.AuthorGlobalSearch(query);
model.PublisherResults = myHandler.PublisherGlobalSearch(query);
#endregion
return View(model);
}
示例12: Create
public ActionResult Create(FormCollection collection)
{
if (collection.Count != 0)
{
BarometerDataAccesLayer.DatabaseClassesDataContext context = DatabaseFactory.getInstance().getDataContext();
BarometerDataAccesLayer.Project insertProject = new BarometerDataAccesLayer.Project();
BarometerDataAccesLayer.ProjectOwner me = new BarometerDataAccesLayer.ProjectOwner();
var ownerInfo =
from u in context.Users
where u.student_number == CurrentUser.getInstance().Studentnummer
select u;
me.User = ownerInfo.First();
insertProject.name = collection.GetValue("FormProject.name").AttemptedValue;
insertProject.description = collection.GetValue("FormProject.description").AttemptedValue;
insertProject.start_date = DateTime.ParseExact(collection.GetValue("FormProject.start_date").AttemptedValue, "dd-MM-yyyy", CultureInfo.InvariantCulture);
insertProject.end_date = DateTime.ParseExact(collection.GetValue("FormProject.end_date").AttemptedValue, "dd-MM-yyyy", CultureInfo.InvariantCulture);
insertProject.ProjectOwners.Add(me);
insertProject.status_name = "Pending";
if (Request.Files.Count != 0)
{
HttpPostedFileBase fileBase = Request.Files[0];
StudentExcel studentExcel = new StudentExcel(insertProject);
studentExcel.Import(fileBase.InputStream);
insertProject.baro_template_id = int.Parse(collection.GetValue("FormProject.baro_template_id").AttemptedValue);
string[] reportDateNames = collection.GetValue("reportDateName[]").AttemptedValue.Split(',');
string[] reportStartDates = collection.GetValue("reportStartDate[]").AttemptedValue.Split(',');
string[] reportEndDates = collection.GetValue("reportEndDate[]").AttemptedValue.Split(',');
EntitySet<BarometerDataAccesLayer.ProjectReportDate> reportDateEntities = new EntitySet<BarometerDataAccesLayer.ProjectReportDate>();
int counter = 0;
foreach (string reportDateName in reportDateNames)
{
BarometerDataAccesLayer.ProjectReportDate tmpReportDate = new BarometerDataAccesLayer.ProjectReportDate();
tmpReportDate.Project = insertProject;
tmpReportDate.week_label = reportDateName;
tmpReportDate.start_date = DateTime.Parse(reportStartDates[counter]);
tmpReportDate.end_date = DateTime.Parse(reportEndDates[counter]);
context.ProjectReportDates.InsertOnSubmit(tmpReportDate);
counter++;
}
context.SubmitChanges();
}
}
return RedirectToAction("List");
}
示例13: BulkCreate
public ActionResult BulkCreate(FormCollection formdata)
{
var InboundMasterID = Convert.ToInt32(((string[])(formdata.GetValue("InboundMasterID").RawValue))[0]);
var addedBooks = new List<InboundBook>();
if (ModelState.IsValid)
{
for (int i = 0; i < 10; i++)
{
var noOfBooks = ((string[])(formdata.GetValue("item.NumberOfBooks").RawValue))[i];
if (!string.IsNullOrWhiteSpace(noOfBooks))
{
addedBooks.Add(new InboundBook
{
NumberOfBooks = Convert.ToInt32(noOfBooks),
BookID= Convert.ToInt32(((string[])(formdata.GetValue("BookID").RawValue))[i])
});
}
}
var groupedData = addedBooks.GroupBy(o => o.BookID).
Select(grp => new InboundBook { BookID = grp.Key, InboundMasterID = InboundMasterID, NumberOfBooks = grp.Sum(o => o.NumberOfBooks) });
// //var matchedItem = db.DistributedBooks.Where(o => o.EventID == distributedbook.EventID && o.BookID == distributedbook.BookID);
// //if (matchedItem.Count() > 1)
// //{
// // throw new Exception("Invalid Data");
// //}
// //else if (matchedItem.Count() == 1)
// //{
// // var item = matchedItem.SingleOrDefault();
// // item.NumberOfBooks = item.NumberOfBooks + distributedbook.NumberOfBooks;
// // db.Entry(item).State = EntityState.Modified;
// //}
foreach (var item in groupedData)
{
AddDistributedBook(item);
}
db.SaveChanges();
return RedirectToAction("Index", new { InboundMasterID });
}
else
return RedirectToAction("ValidationError", "Error", new { errorMesage = "Error occured while doing bulk update" });
}
示例14: Create
public ActionResult Create(CreateModuleViewModel _model, FormCollection collector)
{
BusinessLogicHandler _gateWay = new BusinessLogicHandler();
Module _module = new Module();
_module.ModuleCode = _model.ModuleCode;
_module.ModuleName = _model.ModuleName;
_module.NumberOfScheduledClasses = _model.NumberOfScheduledClasses;
_module.QualificationCode = Convert.ToInt32(collector.GetValue("Qualifications").AttemptedValue);
try
{
if(_gateWay.InsertModule(_module))
{ return RedirectToAction("Index");/*CHANGE THIS HERE*/ }
else
{
#region Load Dropdown
List<Qualification> _qualifications = new List<Qualification>();
_qualifications = _gateWay.GetQualifications();
List<SelectListItem> _qualList = new List<SelectListItem>();
foreach (var _qualification in _qualifications)
{
_qualList.Add(new SelectListItem { Text = _qualification.QualificationName, Value = _qualification.QualificationCode.ToString() });
}
ViewData["Qualifications"] = _qualList;
_model.Qualifications = _qualList;
#endregion
return View(_model);
}
}
catch (Exception ex)
{
ModelState.AddModelError("" + ex.Source, ex);
#region Load Dropdown
List<Qualification> _qualifications = new List<Qualification>();
_qualifications = _gateWay.GetQualifications();
List<SelectListItem> _qualList = new List<SelectListItem>();
foreach (var _qualification in _qualifications)
{
_qualList.Add(new SelectListItem { Text = _qualification.QualificationName, Value = _qualification.QualificationCode.ToString() });
}
ViewData["Qualifications"] = _qualList;
_model.Qualifications = _qualList;
#endregion
return View(_model);
}
}
示例15: Calculate
public ActionResult Calculate(FormCollection collection)
{
try
{
var a = (int)collection.GetValue("a").ConvertTo(typeof(int));
var b = (int)collection.GetValue("b").ConvertTo(typeof(int));
ViewBag.result = a + b;
return this.View("index");
}
catch (Exception)
{
ViewBag.error = @"Both 'a' and 'b' are mandatory and must be numbers!";
return this.View("index");
}
}