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


C# FormCollection.Get方法代码示例

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


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

示例1: AddCustomer

        public string AddCustomer(FormCollection collection, Customer c)
        {
            Message = null;
            AMSEntities ae = new AMSEntities();
            string uname = collection.Get("UserName");
            string pwd = collection.Get("Password");
            string repwd = collection.Get("ReTypePassword");
            if (pwd == repwd)
            {
                using (TransactionScope ts = new TransactionScope())
                {
                    WebSecurity.CreateUserAndAccount(uname, pwd);
                    Roles.AddUserToRole(uname, "Customer");
                    c.MembershipUserID = WebSecurity.GetUserId(uname);
                    c.CustStatus = true;

                    DataStore.Create(c);
                    DataStore.SaveChanges();
                    Emailer.Send(c.CustEmail, "Registration confirmed", "Welcome to AMS");
                    ts.Complete();
                };
                Message = "Successfully Registered";

                return Message;
            }
            else
            {
                return Message;
            }
        }
开发者ID:lightwavebusiness,项目名称:AMS,代码行数:30,代码来源:CustomerBLL.cs

示例2: ChangePassword

        public ActionResult ChangePassword(FormCollection f)
        {
            int Id = int.Parse(Session["LogedUserID"].ToString());
            string passold = f.Get("txtPassOld").ToString();
            string passnew = f.Get("txtPassNew").ToString();
            string passnewre = f.Get("txtPassNewRe").ToString();
            User user = db.Users.Find(Id);
            if(user.Password.Equals(passold))
            {
                if(passnew.Equals(passnewre))
                {
                    db.Users.Find(Id).Password = passnew;
                    Session["Notify"] = "Bạn đã đổi mật khẩu thành công.";
                }
                else
                {
                    Session["Notify"] = "Hai mật khẩu mới không trùng nhau.";
                }
            }
            else
            {
                Session["Notify"] = "Bạn đã nhập sai mật khẩu.";
            }

            return RedirectToAction("Profile", "User");;
        }
开发者ID:LTHD,项目名称:WebBanHang,代码行数:26,代码来源:UserController.cs

示例3: Create

        public ActionResult Create(FormCollection formCollection)
        {
            string title = formCollection.Get("Title");
            string body = formCollection.Get("Body");
            bool isPublic = formCollection.Get("IsPublic").Contains("true");

            IRepository<Category> categoriesRepo = new CategoryRepository();
            IRepository<Post> postsRepo = new PostRepository();
            List<Category> allCategories = (List<Category>)categoriesRepo.GetAll();

            Post post = new Post();
            post.Body = body;
            post.Title = title;
            post.CreationDate = DateTime.Now;
            post.IsPublic = isPublic;

            foreach (Category category in allCategories)
            {
                if (formCollection.Get(category.Id.ToString()).Contains("true"))
                    post.Categories.Add(category);

            }

            postsRepo.Save(post);


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

示例4: RegistIn

 public string RegistIn(FormCollection collection)
 {
     var userName = collection.Get("username");
     var password = collection.Get("password");
     var email = collection.Get("email");
     var phone = collection.Get("phone");
     if (string.IsNullOrEmpty(userName) || string.IsNullOrEmpty(password))
     {
         return HttpRequestResult.StateNotNull;
     }
     var user = new User
     {
         UserName = userName,
         PassWord = password,
         Email = email,
         PhoneNum = phone,
         IsEnable = true,
         CreateTime = DateTime.Now,
         UpdateTime = DateTime.Now
     };
     if (_userBll.Exists(user.UserName))
     {
         return HttpRequestResult.StateExisted;
     }
     var flag = _userBll.Add(user);
     if (flag > 0)
     {
         return HttpRequestResult.StateOk;
     }
     return HttpRequestResult.StateError;
 }
开发者ID:wangz001,项目名称:Funnycar,代码行数:31,代码来源:HomeController.cs

示例5: Create

        public ActionResult Create(FormCollection collection)
        {
            try
            {
                var idList = collection.Get("ids");
                var idArray = idList.Split(",".ToCharArray());

                if (idArray.Length > 0)
                {
                    foreach (var item in idArray)
                    {
                        var gamePriceName = String.Format("game_price_name_{0}", item);
                        var gPrice = String.Format("game_price_price_{0}", item);
                        var name = collection.Get(gamePriceName);
                        var price = collection.Get(gPrice);
                        var gamePrice = new GamePrice();
                        gamePrice.Price = Convert.ToDecimal(price);
                    }
                }

                return RedirectToAction("Index", "Team");
            }
            catch
            {
                return View();
            }
        }
开发者ID:cataylor,项目名称:bananasplit,代码行数:27,代码来源:GamePriceController.cs

示例6: Captcha

        public ActionResult Captcha(FormCollection form)
        {
            var challenge = form.Get<string>("recaptcha_challenge_field", "");

            var validator = new Recaptcha.RecaptchaValidator
            {
                PrivateKey = AppSettings.RecaptchaPrivateKey,
                RemoteIP = GetRemoteIP(),
                Challenge = challenge,
                Response = form.Get<string>("recaptcha_response_field", "")
            };

            Recaptcha.RecaptchaResponse response;

            try
            {
                response = validator.Validate();
            }
            catch (WebException)
            {
                // recaptcha is down - if the challenge had some length (it's usually a massive hash), allow the action - spam will be destroyed by the community
                response = challenge.Length >= 30 ? Recaptcha.RecaptchaResponse.Valid : Recaptcha.RecaptchaResponse.RecaptchaNotReachable;
            }

            if (response == Recaptcha.RecaptchaResponse.Valid)
            {
                Current.SetCachedObjectSliding(CaptchaKey(GetRemoteIP()), true, 60 * 15);
                return Json(new { success = true });
            }

            return  Json(new { success = false });;
        }
开发者ID:jtbandes,项目名称:StackExchange.DataExplorer,代码行数:32,代码来源:CaptchaController.cs

示例7: ValidateSessionFormData

        /// <summary>
        /// validiert die Formulareingaben auf Korrektheit
        /// </summary>
        /// <param name="formData">FormCollection mit den Formulareingaben aus dem Create-Formular</param>
        /// <param name="numExercises">Anzahl der Uebungen im Plan</param>
        /// <returns>true oder false</returns>
        public bool ValidateSessionFormData(FormCollection formData, int numExercises)
        {
            // workoutID und anzahl der Workouts muss numerisch sein
            byte dayID = 0;
            int workoutID = -1;
            if (!Byte.TryParse(formData.Get("dayID"), out dayID) || !Int32.TryParse(formData.Get("workoutID"), out workoutID)) return false;

            DateTime workoutDate = DateTime.MinValue;
            if (formData.Get("session-date").Trim() == "" || !DateTime.TryParse(formData.Get("session-date"), out workoutDate) || workoutDate == DateTime.MinValue)
            {
                return false;
            }

            // pruefen, dass alle Wiederholungs- und Gewichtszahlen numerisch und in einem gewissen Rahmen liegen
            int tmp = -1;
            double dtmp = -1.0;
            string[] weight, reps;
            for (int i = 0; i < numExercises; i++)
            {
                reps = formData.GetValues("reps-" + i);
                weight = formData.GetValues("weight-" + i);
                if ((reps != null || weight != null) && reps.Length != weight.Length) return false;

                for (int j = 0; j < reps.Length; j++)
                {
                    if (!String.IsNullOrEmpty(reps[j].Trim()) && (!Int32.TryParse(reps[j], out tmp) || tmp < 0 || tmp > 1000)) return false;
                    if (!String.IsNullOrEmpty(reps[j].Trim()) && (!Double.TryParse(weight[j], out dtmp) || dtmp < 0.0 || dtmp > 1000.0)) return false;
                    if ((String.IsNullOrEmpty(reps[j].Trim()) && !String.IsNullOrEmpty(weight[j].Trim())) || (!String.IsNullOrEmpty(reps[j].Trim()) && String.IsNullOrEmpty(weight[j].Trim()))) return false;
                }
            }

            return true;
        }
开发者ID:m-boldt,项目名称:Exercise-Yourself,代码行数:39,代码来源:SessionService.cs

示例8: Login

        public ActionResult Login(FormCollection fc)
        {
            string username = fc.Get("tbUsername");
            string password = fc.Get("tbPassword");
            string url = "/Home/";

            VaKEGradeRepository repository = VaKEGradeRepository.Instance;
            Teacher teacher = repository.GetTeacher(username, password);
            if (teacher != null)
            {
                Session["User"] = teacher;
                if (username.ToLower() == "admin") {
                    Session["Role"] = "Admin";
                    url = "/Admin/";
                }
                else if (repository.IsUserClassTeacher(teacher))
                {
                    Session["Role"] = "ClassTeacher";
                    url = "/ClassTeacher/";
                }
                else {
                    Session["Role"] = "Teacher";
                    url = "/Teacher/";
                }
               // VaKEGradeRepository.Instance.GetSubjectsOfTeacher(null, null);
            }

            return Redirect(url);
        }
开发者ID:pranabnth,项目名称:vakegrade,代码行数:29,代码来源:AuthentificationController.cs

示例9: Create

        public ActionResult Create(FormCollection collection)
        {
            var game = new Game();
            try
            {
                var now = DateTime.Now;
                game.EventStartDate = CombineDateAndTime(collection.Get("EventStartDate"), collection.Get("EventStartTime"));
                game.EventEndDate = CombineDateAndTime(collection.Get("EventEndDate"), collection.Get("EventEndTime"));
                var loc = collection.Get("EventLocation");
                if (!String.IsNullOrEmpty(loc))
                {
                    game.EventLocation = collection.Get("EventLocation");
                }
                game.IsActive = true;
                game.VisitingTeamId = Convert.ToInt64(collection.Get("VisitingTeamId"));
                game.TeamId = Convert.ToInt64(collection.Get("TeamId"));
                game.TimeZone = collection.Get("TimeZone");
                game.SeasonId = Convert.ToInt64(collection.Get("SeasonId"));
                game.DateCreated = now;
                game.DateUpdated = now;

                this.repo.Save(game);

                return RedirectToAction("Index");
            }
            catch
            {
                ViewBag.Seasons = this.GetActiveSeasons();
                ViewBag.TeamTypes = this.GetTeamTypes();
                return View(game);
            }
        }
开发者ID:cataylor,项目名称:bananasplit,代码行数:32,代码来源:GameController.cs

示例10: AddUserToRole

        public ActionResult AddUserToRole(FormCollection collection)
        {
            ViewBag.Continental = (db.Continentals);
            if (collection != null)
            {

                string r = collection.Get("Role");
                string u = collection.Get("User");
                         var UserRole = new ApplicationUserRole
                          {

                              RoleId = r,//"29b11ba5-a1cd-454a-aca5-a12f23e89764",
                              UserId =u //"4caa7e95-8129-4c5c-be3f-b377c39f3bb3"

                          };

                         try
                         {
                             db.ApplicationUserRoles.Add(UserRole);
                             db.SaveChanges();
                             ViewData["Role"] = new SelectList(db.Roles, "Id", "Name");
                             ViewData["User"] = new SelectList(db.Users, "Id", "UserName");
                             return View();
                         }
                         catch
                         {
                             ViewData["Role"] = new SelectList(db.Roles, "Id", "Name");
                             ViewData["User"] = new SelectList(db.Users, "Id", "UserName");
                             return View();
                         }

                      }
                      else { return HttpNotFound(); }
        }
开发者ID:CHAISIOL,项目名称:FoodManiacs,代码行数:34,代码来源:RoleController.cs

示例11: Index

        public ActionResult Index(FormCollection collection)
        {
            TournoiWS ts = null;
            string nom = collection.Get(1);
            using (ServiceReference.ServiceClient service = new ServiceReference.ServiceClient())
            {
                TournoiWS tn = service.getTournois().Where(x => x.Nom == nom).First();
                ts = service.playTournoi(tn);
            }
            TournoiViewModel mod = new TournoiViewModel(ts);

            using (ServiceReference.ServiceClient service = new ServiceReference.ServiceClient())
            {
                int butin = service.getPoints(User.Identity.GetUserName());
                mod.Mise = Int32.Parse(collection.Get("Mise"));
                mod.Mise = (mod.Mise < 0 ? 0 : mod.Mise > butin ? butin : mod.Mise);
                mod.Jedi = collection.Get("Jedi");
                bool gagne = mod.Jedi == mod.Matches.list.Where(x => x.Phase == EPhaseTournoiWS.Finale).First().JediVainqueur.Nom;
                mod.Gain = (gagne ? mod.Mise * 2 + 1 : 0);
                var userId = User.Identity.GetUserId();

                mod.Total = service.getPoints(User.Identity.GetUserName());
                mod.Total += (gagne ? mod.Gain : -mod.Mise);
                mod.Total = mod.Total < 0 ? 0 : mod.Total;
                service.setPoints(User.Identity.GetUserName(), mod.Total);
            }

            return View("Details", mod);
        }
开发者ID:BBS007,项目名称:WebServiceJedi,代码行数:29,代码来源:GameController.cs

示例12: Create

        public ActionResult Create(FormCollection collection)
        {
            try
            {
                string name = collection.Get("campaignname");
                int x = -1;
                int y = -1;

                Int32.TryParse(collection.Get("fieldx"), out x);
                Int32.TryParse(collection.Get("fieldy"), out y);

                // Angemeldeten Spieler hinzufügen
                //PlayerInfo pinfo = data.getPlayerByName(User.Identity.Name);

                CampaignInfo newCampaignInfo = new CampaignInfo()
                {
                    campaignId = "",
                    campaignName = name,
                    FieldDimension = new clsSektorKoordinaten() {X = x, Y = y},
                    ListPlayerInfo = new List<PlayerInfo>() { new PlayerInfo() { playerName = User.Identity.Name } }
                };

                ICampaignController ctrl = data.createNewCampaign(newCampaignInfo);
                //ctrl.CampaignEngine.addPlayer(new Player(pinfo) { });
                //data.safeCampaignState(ctrl.CampaignEngine.getState());

                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }
开发者ID:ViGor-Thinktank,项目名称:GCML,代码行数:33,代码来源:CampaignDataController.cs

示例13: CreateBeerPosting

        public ActionResult CreateBeerPosting(FormCollection form)
        {
            UserManager<ApplicationUser> manager = HttpContext.GetOwinContext().GetUserManager<ApplicationUserManager>();

            string beer_name = form.Get("beerposting-name");
            int beer_qty;
            Regex rx = new Regex("[0-9]+$");

            if ((rx.IsMatch(form.Get("beerposting-quantity"))) && (!form.Get("beerposting-quantity").Contains("-")))
            {
                beer_qty = Convert.ToInt32(form.Get("beerposting-quantity"));
            }
            else
            {
                System.Windows.Forms.MessageBox.Show("That's not a valid number. Please try again.");
                return RedirectToAction("Index");
            }

            string beer_note = form.Get("beerposting-note");
            string user_id = User.Identity.GetUserId();
            string user_name = User.Identity.GetUserName();
            ApplicationUser brewLover = hopCentral.Users.FirstOrDefault(u => u.Id == user_id);
            string brewLoverId = brewLover.Id;

            hopCentral.CreatePosting(brewLover, new BeerPosting { OwnerName = user_name, OwnerId = brewLoverId, BeerName = beer_name, Quantity = beer_qty, Note = beer_note });

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

示例14: Create

		public ActionResult Create(FormCollection collection) {
			try {
				ServiceReference.JediWS jedi = new JediWS();
				List<CaracteristiqueWS> caracList = new List<CaracteristiqueWS>();

				using(ServiceReference.ServiceClient service = new ServiceClient()) {
					service.getCaracteristiques().ForEach(x => {
						if(x.Type == ServiceReference.ETypeCaracteristiqueWS.Jedi) {
							caracList.Add(x);
						}
					});

					/* Item1. sur le champs du jedi parce que on a un tuple */
					jedi.Id = 0; // Car creation
					jedi.Nom = Convert.ToString(collection.Get("Item1.Nom"));
					jedi.IsSith = Convert.ToBoolean(collection.Get("Item1.IsSith") != "false"); // Pour que ca marche bien
					jedi.Caracteristiques = new List<CaracteristiqueWS>(); // Pour init

					string[] checkboxes = collection.GetValues("caracteristiques");
					if(checkboxes != null) {
						foreach(string s in checkboxes) {
							//On a que les ids des box selected, on ajoute les caracteristiques
							Int32 caracId = Convert.ToInt32(s);
							jedi.Caracteristiques.Add(caracList.First(x => x.Id == caracId));
						}
					}

					service.addJedi(jedi); // Ajout du jedi
				}

				return RedirectToAction("Index"); // Retour a l'index
			} catch {
				return RedirectToAction("Index");
			}
		}
开发者ID:BBS007,项目名称:WebServiceJedi,代码行数:35,代码来源:JediController.cs

示例15: Add

        public JsonResult Add(FormCollection form)
        {
            var sch = CheckGroup(form);
            bool week;
            int lessonId, lessonType, weekdayId;
            if (sch != null &&
                bool.TryParse(form.Get("week"), out week) &&
                int.TryParse(form.Get("lesson-id"), out lessonId) &&
                int.TryParse(form.Get("lesson-type"), out lessonType) &&
                int.TryParse(form.Get("weekday-id"), out weekdayId))
            {

                sch.IsWeekOdd = week;
                sch.LessonId = lessonId;
                sch.LessonType = lessonType;
                sch.WeekdayId = weekdayId;

                sch.LectorName = _db.Lectors.Add(sch.LectorName);
                _db.Schedule.Add(sch);
                _db.Subjects.Add(sch.SubjectName);
                _db.Auditories.Add(sch.Auditory);
                _db.SaveChanges();
                return Json(sch.SubjectName + " " + sch.Auditory);
            }

            return Json(null);
        }
开发者ID:rkvtsn,项目名称:sch-dev,代码行数:27,代码来源:ScheduleController.cs


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