public string Register(String Uemail, String Upassword)
        {
            string judge;
            OxcoderDataContext personDataContext = new OxcoderDataContext();
            Person person = new Person();
            var query = from s in personDataContext.Person
                        where s.Uemail == Uemail
                        select s;

            //返回Student表中的记录数
            var count = query.Count();
            if (count == 0)//如果有重复的
            {

                person.Uemail = Uemail;
                person.Upassword = Upassword;
                personDataContext.Person.InsertOnSubmit(person);
                personDataContext.SubmitChanges();
                judge = "注册成功";

            }
            else
            {
                judge = "该账号已经被注册";
            }

            return judge;
        }
        // GET: Home
        public ActionResult Index()
        {
            DataAccessLayer.Context context = new DataAccessLayer.Context();

            if (context.Persons.Count() < 1000)
            {
                List <Person> personList = new List <Person>();
                int           counter    = 0;
                while (counter < 2000)
                {
                    string       barcode        = GeneratePersonRendom.GetBarcode();
                    Model.Person personExistObj = context.Persons.FirstOrDefault(p => p.Barcode == barcode);
                    if (personExistObj == null)
                    {
                        personExistObj              = new Person();
                        personExistObj.Address      = "Tehran";
                        personExistObj.Barcode      = barcode;
                        personExistObj.Family       = GeneratePersonRendom.GetFamily();
                        personExistObj.FatherName   = "mohammad";
                        personExistObj.Name         = GeneratePersonRendom.GetName();
                        personExistObj.NationalCode = "99999999";
                        personExistObj.NOId         = 0;
                        personExistObj.Tel          = "09125270217";
                        context.Persons.Add(personExistObj);
                        context.SaveChanges();
                        Lucene.CreateIndex.AddIndex(personExistObj);
                        counter++;
                    }
                }
            }
            return(View());
        }
        public string Login(string Uemail, string Upassword)
        {
            string judge;
            OxcoderDataContext personDataContext = new OxcoderDataContext();
            Person person = new Person();
            var queryUser = from s in personDataContext.Person
                        where s.Uemail == Uemail
                        select s;
            var countForUser = queryUser.Count();
            if (countForUser == 0)//如果没有这个用户
             {
                 judge = "用户不存在";
             }
             else
             {
                 var queryPassword = from s in personDataContext.Person
                        where s.Uemail == Uemail&&s.Upassword == Upassword
                        select s;
                 var countForPassword = queryUser.Count();
                 if (countForPassword == 0)//如果密码错误
                 {
                     judge = "密码错误";
                 }
                 else
                 {
                     judge = "登录成功";
                 }
             }

            return judge;
        }
Exemple #4
0
 public bool Equals(Person obj)
 {
     if (ReferenceEquals(null, obj)) {
         return false;
     }
     if (ReferenceEquals(this, obj)) {
         return true;
     }
     return obj.Id == Id;
 }
        public ActionResult Injected()
        {
            var person = new Person
                         {
                         	Name = "John Doe",
                         	BirthDate = new DateTime(1980, 1, 1),
                         	State = StatesService.GetStates()[1]
                         };

            return View(person);
        }
        public async Task CreateCookie(string key, Model.Person person, int expiredays)
        {
            var options = new CookieOptions();

            options.Expires = DateTime.Now.AddDays(expiredays);
            var value    = Guid.NewGuid().ToString();
            var dbCookie = new StoredCookie {
                Value = value, PersonId = person.Id
            };
            await cookieCommand.Create(dbCookie);

            httpContext.HttpContext.Response.Cookies.Append(key, value, options);
        }
 private static void InserPerson()
 {
     var person = new Person
     {
         Firstname = "Rowne",
         LastName = "Miller",
         SocialSecurityNumber = 12345678
     };
     using (var context = new BreakAwayContext())
     {
         context.Persons.Add(person);
         context.SaveChanges();
     }
 }
Exemple #8
0
 private static void InsertPerson()
 {
     var person = new Person
     {
         FirstName = "Rowan",
         LastName = "Miller",
         SocialSecurityNumber = 12345678,
         Photo = new PersonPhoto { Photo = new Byte[] { 0 } }
     };
     using (var context = new BreakAwayContext())
     {
         context.People.Add(person);
         context.SaveChanges();
     }
 }
 /// <summary>
 /// Register user with adding one to database
 /// </summary>
 /// <param name="name">Name of new user</param>
 /// <param name="surname">Surname of new user</param>
 /// <param name="zal">Student ticket number of new user</param>
 /// <param name="username">Username of new user</param>
 /// <param name="password">Password of new user</param>
 /// <returns></returns>
 public bool registerUser(ParamsForRegister values)
 {
     Model.Person person = new Model.Person {
         Name = values.name, Surname = values.surname, Password = values.password, Photo = userPhoto, Username = values.username
     };
     Model.Student student = new Model.Student {
         TicketNumber = long.Parse(values.ticket), ReportCard = long.Parse(values.zal), PersonID = values.username, GroupID = values.group
     };
     if (service.LoadLogInPersonAsync(values.username) == null)
     {
         service.CreatePersonAsync(person).Wait();
         service.CreateStudentAsync(student).Wait();
         return(true);
     }
     else
     {
         return(false);
     }
 }
        private void LoadData()
        {
            persons.Clear();

            using (UMAIDEntities entities = new UMAIDEntities())
            {
                var dataFromSQL = from o in entities.Persons
                                  select o;

                foreach (var o in dataFromSQL)
                {
                    Model.Person mPerson = new Model.Person();
                    mPerson.FName    = o.FName;
                    mPerson.LName    = o.LName;
                    mPerson.PersonID = o.personID;

                    persons.Add(mPerson);
                }
            }

            lbNames.ItemsSource = persons.OrderBy(c => c.LName).ThenBy(c => c.FName).ToList();
        }
Exemple #11
0
		public void InsertWithIdentity5(string context)
		{
			using (var db = GetDataContext(context))
			{
				try
				{
					for (var i = 0; i < 2; i++)
					{
						db.Person.Delete(p => p.ID > 2);

						var person = new Person
						{
							FirstName = "John" + i,
							LastName  = "Shepard",
							Gender    = Gender.Male
						};

						var id = db.InsertWithIdentity(person);

						Assert.NotNull(id);

						var john = db.Person.Single(p => p.FirstName == "John" + i && p.LastName == "Shepard");

						Assert.NotNull (john);
						Assert.AreEqual(id, john.ID);
					}
				}
				finally
				{
					db.Person.Delete(p => p.ID > 2);
				}
			}
		}
 partial void DeletePerson(Person instance);
 partial void UpdatePerson(Person instance);
 partial void InsertPerson(Person instance);
 public Person GetPerson(Person person)
 {
     return new Person { Name = person.Name + "L", Age = person.Age + 10 };
 }