当前位置: 首页>>代码示例>>C#>>正文


C# Mvc.FormCollection类代码示例

本文整理汇总了C#中System.Web.Mvc.FormCollection的典型用法代码示例。如果您正苦于以下问题:C# FormCollection类的具体用法?C# FormCollection怎么用?C# FormCollection使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


FormCollection类属于System.Web.Mvc命名空间,在下文中一共展示了FormCollection类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Create

        public ActionResult Create(FormCollection collection)
        {
            var item = new Item();

            try
            {
                // bind
                TryUpdateModel(item);

                // set the rest
                item.Type = _itemTypeRepository.GetById(Convert.ToInt32(collection["Type"]));
                item.CreatedDate = DateTime.Now;
                item.ModifiedDate = DateTime.Now;

                // save
                _itemRepository.Add(item);
                _itemRepository.Save();

                return RedirectToAction("Edit", new {id = item.ID});
            }
            catch
            {
                return View(item);
            }
        }
开发者ID:pattersonc,项目名称:ShowOff,代码行数:25,代码来源:ItemController.cs

示例2: SummaryForApprove

        public ActionResult SummaryForApprove(int id, FormCollection form)
        {
            var campaign = OperationContext.ServiceSession.EM_CampaignsService.Get(c => c.CampaignID == id).FirstOrDefault();
            if (campaign != null)
            {
                campaign.Approved = true;
                campaign.ApprovedBy = OperationContext.CurrentUser.employeeLoginName;
                campaign.ApprovedDate=DateTime.Now;
                OperationContext.ServiceSession.SaveChange();

                //invoke stored procedure, populate data to campaignInstance.
                Entities entity = new Entities();
                var emailInstanceId =
                    OperationContext.ServiceSession.EM_EmailInstancesService.Get(e => e.CampaignID == id)
                        .FirstOrDefault()
                        .EmailInstanceID;
                entity.EM_CampaignInstances_INSERT(emailInstanceId);

                return OperationContext.SendAjaxMessage(AjaxMessageStatus.OperationSuccess, "", "", null);
            }
            else
            {
                return OperationContext.SendAjaxMessage(AjaxMessageStatus.OperationFailed, "campaign is not found", "",
                    null);
            }
        }
开发者ID:simon8029,项目名称:EmailPromotionManagementDemo,代码行数:26,代码来源:SummaryController.cs

示例3: Delete

 public ActionResult Delete(FormCollection collection, long[] ids)
 {
     if (ids.Length == 0)
     {
         FlashWarn("请选择要删除的记录。");
         return Close();
     }
     using (var session = new SessionFactory().OpenSession())
     {
         session.BeginTransaction();
         var models = session.Find<Role>(m => m.Id.In(ids));
         if (models == null || models.Count == 0)
         {
             FlashFailure("你要删除的角色不存在或者已被删除!");
             return Close();
         }
         if (models.Any((m => "SYSTEM".Equals(m.CreatedBy))))
         {
             FlashFailure("你要删除的角色包含系统内置角色,无法删除!");
             return Close();
         }
         var roleIds = models.Select(n => n.Id).ToArray();
         if (session.Delete(models) &&
             session.Delete<NavigationPriviledge>(m => m.Flag.Equals(NavigationPriviledge.RoleType) && m.OwnerId.In(roleIds)) &&
             session.Delete<AccountNavigationRef>(m => m.Type.Equals(AccountNavigationRef.RoleType) && m.OwnerId.In(roleIds)))
         {
             session.Commit();
             FlashInfo("角色删除成功");
             return Close();
         }
         session.Rollback();
         FlashError("角色删除失败!");
         return View();
     }
 }
开发者ID:dalinhuang,项目名称:info_platform_i,代码行数:35,代码来源:RoleController.cs

示例4: HireGroup

 /// <summary>
 /// Hire Group Selection screen
 /// </summary>
 public ActionResult HireGroup(FormCollection collection)
 {
     if (collection["HireGroupDetailId"] != null)
     {
         var bookingView = new BookingViewModel
         {
             HireGroupDetailId = Convert.ToInt64(collection["HireGroupDetailId"]),
             OperationWorkPlaceId = Convert.ToInt64(collection["OperationWorkPlaceId"]),
             OperationWorkPlaceCode = Convert.ToString(collection["OperationWorkPlaceCode"]),
             StartDt = Convert.ToDateTime(collection["StartDateTime"]),
             EndDt = Convert.ToDateTime(collection["EndDateTime"]),
             TariffTypeCode = Convert.ToString(collection["TariffTypeCode"])
         };
         TempData["Booking"] = bookingView;
         return RedirectToAction("Services");
     }
     //hire group get
     var bookingViewModel = TempData["Booking"] as BookingViewModel;
     var hireGroupRequest = new GetHireGroupRequest();
     if (bookingViewModel != null)
     {
         hireGroupRequest.StartDateTime = bookingViewModel.StartDt;
         hireGroupRequest.EndDateTime = bookingViewModel.EndDt;
         hireGroupRequest.OutLocationId = bookingViewModel.OperationWorkPlaceId;
         hireGroupRequest.ReturnLocationId = bookingViewModel.OperationWorkPlaceId;
         hireGroupRequest.DomainKey = 1;
     }
     IEnumerable<HireGroupDetail> hireGroupDetails = webApiService.GetHireGroupList(hireGroupRequest)  .AvailableHireGroups.Select(x => x.CreateFrom());
     ViewBag.BookingVM = TempData["Booking"] as BookingViewModel;
     return View(hireGroupDetails.ToList());
 }
开发者ID:innoist,项目名称:GF-FRS,代码行数:34,代码来源:BookingController.cs

示例5: Edit

 public ActionResult Edit(int id, FormCollection collection)
 {
     var model = this.ProjectService.GetFile(id);
     this.TryUpdateModel<Files>(model);
     this.ProjectService.SaveFile(model);            
     return this.RefreshParent();
 }
开发者ID:shenxingfu,项目名称:HaoTang,代码行数:7,代码来源:FilesController.cs

示例6: AjaxAddComment

 public ActionResult AjaxAddComment(FormCollection Fm)
 {
     Maticsoft.BLL.SNS.Comments comments = new Maticsoft.BLL.SNS.Comments();
     Maticsoft.Model.SNS.Comments comModel = new Maticsoft.Model.SNS.Comments();
     int num = Globals.SafeInt(Fm["TargetId"], 0);
     int num2 = 3;
     int num3 = 0;
     string source = ViewModelBase.ReplaceFace(Fm["Des"]);
     comModel.CreatedDate = DateTime.Now;
     comModel.CreatedNickName = base.currentUser.NickName;
     comModel.CreatedUserID = base.currentUser.UserID;
     comModel.Description = source;
     comModel.HasReferUser = source.Contains<char>('@');
     comModel.IsRead = false;
     comModel.ReplyCount = 0;
     comModel.TargetId = num;
     comModel.Type = num2;
     comModel.UserIP = base.Request.UserHostAddress;
     num3 = comments.AddEx(comModel);
     if (num3 > 0)
     {
         comModel.CommentID = num3;
         comModel.Description = ViewModelBase.RegexNickName(comModel.Description);
         List<Maticsoft.Model.SNS.Comments> model = new List<Maticsoft.Model.SNS.Comments> {
             comModel
         };
         return this.PartialView("CommentList", model);
     }
     return base.Content("No");
 }
开发者ID:huaminglee,项目名称:myyyyshop,代码行数:30,代码来源:AlbumController.cs

示例7: EndDateTimeDateTimeUtcValueIsSetCorrectlyFromStartDateTimeLocalDateLocalTimeValues

        public void EndDateTimeDateTimeUtcValueIsSetCorrectlyFromStartDateTimeLocalDateLocalTimeValues()
        {
            var timeZoneId = TimeZoneInfo.FindSystemTimeZoneById("Eastern Standard Time").StandardName;
            var startDateTimeLocalDate = "01/16/2012";
            var startDateTimeLocalTime = "1:00";
            var startDateTimeDateTimeLocalValue = startDateTimeLocalDate + " " + startDateTimeLocalTime;

            var endDateTimeLocalDate = "01/16/2012";
            var endDateTimeLocalTime = "3:00";
            var endDateTimeDateTimeLocalValue = endDateTimeLocalDate + " " + endDateTimeLocalTime;

            var form = new FormCollection
                           {
                               {"test.StartDateTime.LocalDate", startDateTimeLocalDate},
                               {"test.StartDateTime.LocalTime", startDateTimeLocalTime},
                               {"test.EndDateTime.LocalTime", endDateTimeLocalTime},
                               {"test.TimeZoneName", timeZoneId}
                           };
            var result = BindModelByFormCollection(form);

            Assert.AreEqual(DateTime.Parse(startDateTimeDateTimeLocalValue), result.StartDateTime.DateTimeLocalValue);
            Assert.AreEqual(DateTime.Parse(startDateTimeDateTimeLocalValue).ToUniversalTime(timeZoneId), result.StartDateTime.DateTimeUtcValue);

            Assert.AreEqual(DateTime.Parse(endDateTimeDateTimeLocalValue), result.EndDateTime.DateTimeLocalValue);
            Assert.AreEqual(DateTime.Parse(endDateTimeDateTimeLocalValue).ToUniversalTime(timeZoneId), result.EndDateTime.DateTimeUtcValue);
        }
开发者ID:rantoine,项目名称:CSharpMVCDateTimeConversionFramework,代码行数:26,代码来源:UiDateTimeRangeModelBinderTest.cs

示例8: Create

        public ActionResult Create(string entityName, FormCollection collection)
        {
            var entity = Admin.GetEntity(entityName);
            if (entity == null)
            {
                return RedirectToAction("NotFound", new { entityName });
            }

            try
            {
                var savedId = _entityService.Create(entity, collection, Request.Files);
                if (savedId != null)
                {
                    _notificator.Success(IlaroAdminResources.AddSuccess, entity.Verbose.Singular);

                    return SaveOrUpdateSucceed(entityName, savedId);
                }
            }
            catch (Exception ex)
            {
                _log.Error(ex);
                _notificator.Error(ex.Message);
            }

            var model = new EntityCreateOrEditModel
            {
                Entity = entity,
                PropertiesGroups = _entityService.PrepareGroups(entity)
            };

            return View(model);
        }
开发者ID:anupvarghese,项目名称:Ilaro.Admin,代码行数:32,代码来源:EntityController.cs

示例9: AddUser

        public void AddUser(FormCollection collection, User user)
        {
            UserBLL ub = new UserBLL();
             String message=ub.AddNewUser(collection,user);

             Index();
        }
开发者ID:lightwavebusiness,项目名称:AMS,代码行数:7,代码来源:UserController.cs

示例10: Create

        public ActionResult Create(FormCollection formCollection)
        {
            try {
                Order order = new Order();
                order.ClientID = WebSecurity.CurrentUserId;
                order.Date = DateTime.Now;
                order.ConditionID = db.Conditions.Where(condition => condition.Name.Equals("Оформлен")).FirstOrDefault().ID;
                order.Address = formCollection["address"];
                db.Orders.Add(order);
                db.SaveChanges();
                Cart cart = (Cart)Session["Cart"];
                List<OrderItem> orderItems = new List<OrderItem>();
                foreach (var item in cart.Content) {
                    OrderItem orderItem = new OrderItem();
                    orderItem.BookID = item.Key;
                    orderItem.Count = item.Value;
                    orderItem.OrderID = order.ID;
                    orderItems.Add(orderItem);
                }
                order.OrderItems = orderItems;
                db.Entry(order).State = EntityState.Modified;
                db.SaveChanges();
                ((Cart)Session["Cart"]).Clear();
            } catch {

            }
            return RedirectToAction("Index");
        }
开发者ID:MAKAR1031,项目名称:BookStore,代码行数:28,代码来源:OrdersController.cs

示例11: Edit

        public ActionResult Edit(FormCollection collection)
        {
            if (!User.Identity.IsAuthenticated)
            {
                return RedirectToAction("Index");
            }

            try
            {
                Article_section sec = db.CreateObject<Article_section>();

                sec.Article_id = Int32.Parse(collection["Article_id"]);
                sec.User_name = User.Identity.Name;
                sec.Section_heading = collection["Section_heading"];
                sec.Section_text = collection["Section_text"];
                sec.Pub_date = DateTime.Now;
                sec.delete_flag = 0;
                sec.Parent_section = Int32.Parse(collection["Parent_section"]);
                sec.Section_order = Int32.Parse(collection["Section_order"]);

                db.SaveChanges();
                return RedirectToAction("Wiki/Details/" + sec.Article.Title);

            }
            catch
            {
                return View();
            }
        }
开发者ID:martinSternelius,项目名称:Wikid-C-,代码行数:29,代码来源:SectionController.cs

示例12: Create

        public ActionResult Create(FormCollection collection)
        {
            try
            {
                var courseToSubmit = new Course
                {
                    CreatedByUsername = User.Identity.Name,
                    LastUpdateByUsername = User.Identity.Name,
                    CreationDate = DateTime.Now,
                    Description = collection["description"],
                    Name = collection["name"],
                    LastUpdated = DateTime.Now,
                    State = CourseState.Active,
                    NumberOfCourseCompletions = 0
                };

                CoursesModel cm = new CoursesModel();
                var savedCourse = cm.AddOrUpdateCourse(courseToSubmit);

                return RedirectToAction("Create", "CourseContents", new { id = savedCourse.Id });
            }
            catch
            {
                return View();
            }
        }
开发者ID:starvational,项目名称:BizCollege,代码行数:26,代码来源:CoursesController.cs

示例13: Create

        public ActionResult Create(FormCollection form, int? parentId)
        {
            var building = new Building
                             {
                                 Name = Utils.Transliterator.Transliterate(form["Name"])
                             };
            TryUpdateModel(building, new[] { "Title", "SortOrder", "SeoDescription", "SeoKeywords", "ContentType" });
            building.CategoryLevel = 1;
            building.Active = true;
            building.Text = HttpUtility.HtmlDecode(form["Text"]);

            if (parentId.HasValue)
            {
                var parent = _context.Building.First(c => c.Id == parentId);
                parent.Children.Add(building);
            }
            else
            {
                _context.AddToBuilding(building);
            }
            _context.SaveChanges();


            switch (form["ContentType"])
            {
                case "1": return RedirectToAction("Buildings", "Home", new { area = "" });
                case "2": return RedirectToAction("Products", "Home", new { area = "" });
                case "3": return RedirectToAction("Documents", "Home", new { area = "" });
                case "4": return RedirectToAction("WhereToBuy", "Home", new { area = "" });
                case "5": return RedirectToAction("About", "Home", new { area = "" });
            }
            return RedirectToAction("Buildings", "Home", new { area = "" });
        }
开发者ID:fathurxzz,项目名称:aleqx,代码行数:33,代码来源:BuildingController.cs

示例14: Index

 public ActionResult Index(FormCollection collection)
 {
     if (!AttendeeRegistrationIsOpen())
     {
         return View("RegistrationClosed");
     }
     var newAttendee = new Attendee();
     // This will try to update all the fields in the model based on the form collection
     if (TryUpdateModel(newAttendee, "Attendee", collection))
     {
         _repository.AddAttendee(newAttendee);
         _repository.Save();
         SettingsData settings = SettingsData.Default;
         //TODO: localize string replacement
         var message = new MailMessage(settings.EmailFrom,
                                       newAttendee.People.email,
                                       settings.RegistrationSubject,
                                       settings.RegistrationMessage.Replace(
                                         "{name}", newAttendee.People.name).Replace(
                                             "{role}", "Attendee"));
         try
         {
             Mailer.Send(message);
         }
         catch
         {
             //TODO: log this
         }
         return RedirectToAction("Success");
     }
     // TODO: make validation messages show
     // this isn't showing error messages; eventually that should be investigated
     AttendeeEditData data = MakeEditDateFromAttendee(newAttendee);
     return RedirectToAction("Index", data);
 }
开发者ID:quad341,项目名称:Conferenceware,代码行数:35,代码来源:AttendeeRegistrationController.cs

示例15: Create

        public ActionResult Create(CompanyAdvice companyAdvice, FormCollection form)
        {
            if (companyAdvice.CompanysId == null)
            {
                ModelState.AddModelError("CompanysId", "Please choose a company.");
            }
            ValidateAdvice(companyAdvice);

            if (ModelState.IsValid)
            {
                try
                {
                    _adviceApplicationService.AddCompanyAdvice(CurrentMentor, companyAdvice);

                    return RedirectToAction("Index", "Advice");
                }
                catch
                {
                    return RedirectToAction("Create");
                }
            }

            var companies = _companyApplicationService.GetAllCompanies();
            ViewData["Companies"] = new SelectList(companies, "Id", "CompanyName", companyAdvice.CompanysId);
            ViewData["Semaphores"] = _semaphoreApplicationService.GetAllSemaphores();
            SetAdviceTagViewData();
            return View(companyAdvice);
        }
开发者ID:consumentor,项目名称:Server,代码行数:28,代码来源:CompanyAdviceController.cs


注:本文中的System.Web.Mvc.FormCollection类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。