예제 #1
0
        public void GetUsers()
        {
            // Arrange
            UsersController controller = new UsersController(repository);

            User user = new User();
            user.Login = "******";
            user.Password = "******";
            user.Name = "ololosha";
            user.userId = Guid.NewGuid();
            controller.Post(user);

            user.userId = Guid.NewGuid();
            controller.Post(user);

            user.userId = Guid.NewGuid();
            controller.Post(user);

            // Act
            IEnumerable<User> result = controller.Get();

            // Assert
            Assert.IsNotNull(result);
            Assert.AreEqual(4, result.Count());
        }
        private async void OnShowDetails(User user)
        {
            var detailsWindowViewModel = ViewModelFactory.Resolve<UserDetailsWindowViewModel>();
            detailsWindowViewModel.User = user;

            var result = await detailsWindowViewModel.ShowDialog();
        }
예제 #3
0
        /// <summary>
        /// This method is used to create a User, an account and the user's selected roles
        /// </summary>
        /// <param name="user">This parameter is of type User and holds all the details that need to be
        /// stored in the database</param>
        /// <param name="roles">This parameter consists of a List of type int and holds all the details that need to be
        /// stored in the database</param>
        /// <param name="a">This parameter is of type Account and holds all the details that need to be
        /// stored in the database</param>
        public void Create(Common.User user, List <int> roles, Common.Account a)
        {
            //RegistrationResult result = RegistrationResult.Successful;
            //Account checkAccount = this.getAccountByUsername(a.Username);
            //User checkEmail = this.getUserByEmail(user.Email);

            //if (checkAccount == null && checkEmail == null)
            //{
            foreach (int roleID in roles)
            {
                Role r = new DARole(entities).GetRoleByID(roleID);
                a.Role.Add(r);
            }

            //Account ac = this.getAccountByUsername(a.Username);
            //user.AccountID = ac.ID;
            new DAUser(this.entities).Create(user);
            //    result = RegistrationResult.Successful;
            //}
            //else
            //{
            //    if (checkAccount != null)
            //    {
            //        result = RegistrationResult.usernameExists;
            //    }
            //    else
            //    {
            //        result = RegistrationResult.EmailExists;
            //    }
            //}
            //return result;
        }
예제 #4
0
        public ActionResult CreateUser(RegistrationModel model)
        {
            if (model.Password.ToString().Length < 6)
            {
                ViewBag.Message = "Password length must be at least 6 characters.";
            }
            else if (new UserAccountServ.UserAccountClient().GetAccountByUsername(model.Username.ToString()) != null)
            {
                ModelState.AddModelError("", "Username taken.");
                ViewBag.Message = "Username already taken.";
            }
            else if (new UserAccountServ.UserAccountClient().GetUserByEmail(model.Email.ToString()) != null)
            {
                ModelState.AddModelError("", "Email taken.");
                ViewBag.Message = "Email already taken.";
            }
            else if (new UserAccountServ.UserAccountClient().GetAccountByPIN(model.PIN) != null)
            {
                ModelState.AddModelError("", "PIN taken.");
                ViewBag.Message = "PIN already taken.";
            }
            else
            {
                Account acc = new UserAccountServ.UserAccountClient().GetAccountByUsername(model.Username);
                int roleID = 0;
                List<int> add = new List<int>();

                for (int i = 0; i < model.roles.Count; i++)
                {
                    if (model.checkboxes[i].Checked)
                    {
                        roleID = model.roles[i].ID;
                        add.Add(roleID);
                    }
                }
                int[] arraylist = add.ToArray();

                User u = new User();
                u.Name = model.Name;
                u.Surname = model.Surname;
                u.Email = model.Email;
                u.Mobile = model.Mobile;
                u.ResidenceName = model.ResidenceName;
                u.StreetName = model.StreetName;

                Account a = new Account();
                a.Username = model.Username;
                a.Password = model.Password;
                a.PIN = model.PIN;

                new UserAccountServ.UserAccountClient().AddUser(u, arraylist, a);

                UtilitiesApplication.Encryption encrytion = new UtilitiesApplication.Encryption();
                ViewBag.Token = "Your token is  " + encrytion.EncryptTripleDES(model.Password.ToString(), model.PIN.ToString()) + "  Please use this to log in.";

            }

            return View(model);
        }
예제 #5
0
 public void AddUser(Common.User user)
 {
     if (user == null)
     {
         throw new ArgumentException("user");
     }
     usersDAO.AddUser(user);
 }
예제 #6
0
 public ActionResult Create(Common.User user, List <int> rewards)
 {
     if (ModelState.IsValid)
     {
         data.AddUser(user, rewards);
         return(RedirectToAction("Index"));
     }
     return(View());
 }
예제 #7
0
 public static User CastUser(Common.User user)
 {
     return(user == null ? null : new User()
     {
         Id = user.Id,
         isVolunteer = user.isVolunteer,
         Password = user.Password,
         UserName = user.UserName
     });
 }
        private void OnShowDetails(User user)
        {
            var detailsWindowViewModel = ViewModelFactory.Resolve<UserDetailsWindowViewModel>();
            detailsWindowViewModel.User = user;

            detailsWindowViewModel.Closed +=
                (s, e) => { /* что-то делаем на закрытии окна */ };

            detailsWindowViewModel.Show();
        }
예제 #9
0
파일: AddUserForm.cs 프로젝트: vgamula/Lana
 public AddUserForm(User user = null)
 {
     InitializeComponent();
     db = new DatabaseEntities();
     this._user = user;
     if (this._user != null)
     {
         textBoxUsername.Text = this._user.Username;
         richTextBoxDetails.Text = this._user.Details;
     }
 }
예제 #10
0
 public Status AddUser(User user)
 {
     if(_ListOfUsers.Exists(x => x.ID == user.ID))
     {
         _ListOfUsers[_ListOfUsers.FindIndex(x => x.ID == user.ID)] = user;
     }
     else
     {
         _ListOfUsers.Add(user);
     }
     return Status.Ok;
 }
예제 #11
0
 public ActionResult Index(string login, string name, string password)
 {
     User user = new User();
     user.Login = login;
     user.Name = name;
     user.Password = password;
     user.userId = Guid.NewGuid();
     RepositoryResult<User> resultAdd = repository.User.AddUser(user);
     if(resultAdd.IsSuccessStatusCode) {
         RepositoryResult<IEnumerable<User>> resultGet = repository.User.GetUsers();
         if(resultGet.IsSuccessStatusCode) {
             AccountModel accountModel = new AccountModel();
             return View("Register", accountModel);
         } else {
             throw new InvalidOperationException(resultGet.Exception.GetBaseException().Message);
         }
     } else {
         throw new InvalidOperationException(resultAdd.Exception.GetBaseException().Message);
     }
 }
예제 #12
0
        public void GetUser()
        {
            // Arrange
            UsersController controller = new UsersController(repository);
            User user=new User();
            user.Login = "******";
            user.Password = "******";
            user.Name = "ololosha";
            user.userId=Guid.NewGuid();
            controller.Post(user);

            // Act

            User result = controller.Get("*****@*****.**","123456");

            // Assert
            Assert.IsNotNull(result);
            Assert.AreEqual("*****@*****.**", result.Login);
            Assert.AreEqual("ololosha", result.Name);
            Assert.AreEqual("123456", result.Password);
        }
예제 #13
0
    protected void Page_Load(object sender, EventArgs e)
    {
        String updateInfo = "Latest changes -br--br-";

        client = new Client.ServerServicesClient();
        foreach (String values in Request.Form.Keys)
        {
            List <String> names = values.Split(',').ToList <String>();
            if (names != null)
            {
                String course       = names.ElementAt(0).Trim();
                String courseuserid = names.ElementAt(2).Trim();
                System.Diagnostics.Debug.WriteLine(course + " userid: " + courseuserid);
                client.UpdateReported(Convert.ToInt32(course), Convert.ToInt32(courseuserid));
                Common.Task courseName = client.getTask(Convert.ToInt32(course));
                Common.User firstName  = client.GetUserFromId(Convert.ToInt32(courseuserid));
                String      cn         = courseName.Name;
                String      fn         = firstName.Firstname;
                String      ln         = firstName.Lastname;
                updateInfo += "Approved " + courseName.Name + " for " + fn + " " + ln + "-br-";
            }
        }
        Response.Redirect("MainLadok.aspx?latest=" + updateInfo, true);
    }
		protected override void OnCreate (Bundle bundle)
		{
			base.OnCreate (bundle);

			SetContentView (Resource.Layout.Login);

			_loginET = FindViewById<EditText> (Resource.Id.login);
			_passwordET = FindViewById<EditText> (Resource.Id.password);
			FindViewById<Button> (Resource.Id.login_btn).Click += async (object sender, EventArgs e) => {
				Log.Info ("login: '******' password: '******'", _loginET.Text, _passwordET.Text);
				_current = new User (){ Login = _loginET.Text, Password = _passwordET.Text };
				ServiceLocator.ServerService.Login (_current, LoginSuccess, LoginFailed);
			};

			_current = ServiceLocator.UserService.LoadUser ();
			if (_current != null) {
				Log.Info ("user saved");
				_isUserSaved = true;
				ServiceLocator.ServerService.Login (_current, LoginSuccess, LoginFailed);
			} else {
				Log.Info ("user not saved");
				_isUserSaved = false;
			}
		}
예제 #15
0
        public async Task<ActionResult> Register(RegisterViewModel model)
        {
            if (ModelState.IsValid)
            {
                var user = new User()
                {
                    FirstName = model.FirstName,
                    LastName = model.LastName,
                    UserName = model.Email,
                    Email = model.Email,
                    Telephone = model.Telephone
                };

                var userExist = await UserManager.FindByNameAsync(user.UserName);
                if (userExist != null)
                {
                    ModelState.AddModelError(
                        model.GetPropertyName(() => model.Email),
                        "Email already exists");

                    return View(model);
                }

                var result = await UserManager.CreateAsync(user, model.Password);
                if (result.Succeeded)
                {
                    await SignInAsync(user, isPersistent: false);
                    return RedirectToAction("Success", "Account");
                }
                else
                {  
                    AddErrors(result);
                }
            }

            // If we got this far, something failed, redisplay form
            return View(model);
        }
 private void OnSelectedUserChanged(object sender, UserChangedEventArgs userChangedEventArgs)
 {
     User = userChangedEventArgs.User;
 }
예제 #17
0
 public void Step_with_object(User User)
 {
 }
예제 #18
0
 public ActionResult Edit(Common.User user)
 {
     return(View("Create", user));
 }
예제 #19
0
        public User GetUserFromId(int userId)
        {
            SqlDataReader reader = null;
            User user = null;
            using (SqlCommand c = new SqlCommand(SELECT_USER_WITH_ID, connection))
            {
                c.Parameters.AddWithValue("user", userId);
                reader = c.ExecuteReader();
                if (reader.HasRows)
                {
                    reader.Read();

                        int id = reader.GetInt32(0);
                        string username = reader.GetString(1);
                        string ssn = reader.GetString(3);
                        string lastname = reader.GetString(4);
                        string firstname = reader.GetString(5);
                        string email = reader.GetString(6);
                        int accesslevel = reader.GetInt32(7);
                        user = new User(id, username, ssn, lastname, firstname, email, accesslevel);

                }
            }
            reader.Close();
            return user;
        }
예제 #20
0
 public Common.Score CreateScore(int points, Common.Game game, Common.User user)
 {
     return(controller.CreateScore(points, game.ToPOCO(), user.ToPOCO()).ToDTO());
 }
예제 #21
0
 public int AddUser(int sessionId,User user)
 {
     int userId = -1;
     if (GetUser(sessionId).Accesslevel == User.ADMIN && user.Accesslevel >= User.STUDENT && user.Accesslevel <= User.ADMIN)
     {
         try
         {
             userId = sqlManager.AddUser(user);
         }
         catch (Exception e)
         {
             Console.WriteLine(e.Message);
         }
     }
     return userId;
 }
예제 #22
0
 public int AddUser(User user)
 {
     SqlDataReader reader = null;
     int userId;
     using (SqlCommand c = new SqlCommand(ADD_USER, connection))
     {
         c.Parameters.AddWithValue("name", user.Username);
         c.Parameters.AddWithValue("password", user.Password);
         c.Parameters.AddWithValue("ssn", user.Ssn);
         c.Parameters.AddWithValue("lastname", user.Lastname);
         c.Parameters.AddWithValue("firstname", user.Firstname);
         c.Parameters.AddWithValue("email", user.Email);
         c.Parameters.AddWithValue("access", user.Accesslevel);
         reader = c.ExecuteReader();
         reader.Read();
         userId = reader.GetInt32(0);
     }
     reader.Close();
     return userId;
 }
예제 #23
0
 /// <summary>
 /// Deprecated Method for adding a new object to the User EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToUser(User user)
 {
     base.AddObject("User", user);
 }
 public void OnSelectedUserChanged(User user)
 {
     SelectedUserChanged?.Invoke(this, new UserChangedEventArgs(user));
 }
예제 #25
0
        public void UserUpdate()
        {
            // Arrange
            UsersController controller = new UsersController(repository);
            User user = new User();
            user.Login = "******";
            user.Password = "******";
            user.Name = "ololosha";

            Guid current_guid = Guid.NewGuid();
            user.userId = current_guid;

            controller.Post(user);

            // Act

            user.Name = "IAmWinner";
            user.Password = "******";

            controller.Put(user);

            User result = controller.Get(current_guid);

            // Assert
            Assert.IsNotNull(result);
            Assert.AreEqual("*****@*****.**", result.Login);
            Assert.AreEqual("IAmWinner", result.Name);
            Assert.AreEqual("z7vBA2a1", result.Password);
            Assert.AreEqual(current_guid, user.userId);
        }
예제 #26
0
 public User GetUser(int sessionId)
 {
     SqlDataReader reader = null;
     using (SqlCommand c = new SqlCommand(GET_USER_INFO, connection))
     {
         c.Parameters.AddWithValue("sessionid", sessionId);
         reader = c.ExecuteReader();
         User user = null;
         if (reader.HasRows)
         {
             reader.Read();
             int id = reader.GetInt32(0);
             string username = reader.GetString(1);
             string password = reader.GetString(2);
             string ssn = reader.GetString(3);
             string lastname = reader.GetString(4);
             string firstname = reader.GetString(5);
             string email = reader.GetString(6);
             int accesslevel = reader.GetInt32(7);
             int sessionid = reader.GetInt32(8);
             int stateId = reader.GetInt32(9);
             int stateCourse = reader.GetInt32(10);
             user = new User(id, username, password, ssn , lastname , firstname , email , accesslevel , sessionid, stateId, stateCourse);
         }
         reader.Close();
         return user;
     }
 }
예제 #27
0
        public async Task<ActionResult> ExternalLoginConfirmation(ExternalLoginConfirmationViewModel model, string returnUrl)
        {
            if (User.Identity.IsAuthenticated)
            {
                return RedirectToAction("Manage");
            }

            if (ModelState.IsValid)
            {
                // Get the information about the user from the external login provider
                var info = await AuthenticationManager.GetExternalLoginInfoAsync();
                if (info == null)
                {
                    return View("ExternalLoginFailure");
                }
                var user = new User() { UserName = model.UserName };
                var result = await UserManager.CreateAsync(user);
                if (result.Succeeded)
                {
                    result = await UserManager.AddLoginAsync(user.Id, info.Login);
                    if (result.Succeeded)
                    {
                        await SignInAsync(user, isPersistent: false);
                        return RedirectToLocal(returnUrl);
                    }
                }
                AddErrors(result);
            }

            ViewBag.ReturnUrl = returnUrl;
            return View(model);
        }
예제 #28
0
 private async Task SignInAsync(User user, bool isPersistent)
 {
     AuthenticationManager.SignOut(DefaultAuthenticationTypes.ExternalCookie);
     var identity = await UserManager.CreateIdentityAsync(user, DefaultAuthenticationTypes.ApplicationCookie);
     AuthenticationManager.SignIn(new AuthenticationProperties() { IsPersistent = isPersistent }, identity);
 }
예제 #29
0
        public ActionResult CreateUser(string code, string userName, string userProfileName, string screenName, string email, DateTime?expiredDate, double?discountPercent, bool status, string password)
        {
            try
            {
                if (!_userBusiness.CheckExistUserName(userName))
                {
                    var user = new Common.User();
                    user.CompanyId               = 0;
                    user.Createdate              = DateTime.Now;
                    user.Description             = "";
                    user.FailedLoginAttemp       = 0;
                    user.Lockout                 = true;
                    user.LockoutDate             = DateTime.Now;
                    user.Logindate               = DateTime.Now;
                    user.Modifydate              = DateTime.Now;
                    user.Password                = Common.util.Common.GetMd5Sum(password);
                    user.PasswordEncrypted       = true;
                    user.PasswordEncryptedMethod = "MD5";
                    user.PasswordModify_date     = DateTime.Now;
                    user.Screenname              = screenName;
                    user.Expireddate             = expiredDate;

                    if (discountPercent != null)
                    {
                        user.DiscountPercent = (double)discountPercent;
                    }
                    else
                    {
                        user.DiscountPercent = 0;
                    }

                    if (status)
                    {
                        user.Status = (int)Common.util.Common.USER_STATUS.ACTIVE;
                    }
                    else
                    {
                        user.Status = (int)Common.util.Common.USER_STATUS.NOACTIVE;
                    }

                    user.IsSuperUser = false;
                    user.Username    = userName;

                    var userProfile = new UserProfile
                    {
                        Code       = code,
                        Name       = userProfileName,
                        Email      = email,
                        Createdate = DateTime.Now
                    };
                    user.UserProfile = userProfile;

                    _userBusiness.AddNew(user);
                    ViewData["ErrMessage"] = "Thêm mới thành công user";
                    ViewData["status_"]    = true;
                }
                else
                {
                }
                return(RedirectToAction("Index"));
            }
            catch (FaultException ex)
            {
                var    exep    = Function.GetExeption(ex);
                var    codeExp = exep[1];
                string url     = "Error/ErrorFunction/" + codeExp;
                return(RedirectToActionPermanent(url));
            }
        }
예제 #30
0
 public IEnumerable <Common.Score> GetScoresPerUser(Common.User user)
 {
     return(controller.GetScoresPerUser(user.ToPOCO()).Select(u => u.ToDTO()));
 }
 /// <summary>
 /// Create a new User object.
 /// </summary>
 /// <param name="username">Initial value of the Username property.</param>
 /// <param name="password">Initial value of the Password property.</param>
 /// <param name="email">Initial value of the Email property.</param>
 /// <param name="pin">Initial value of the Pin property.</param>
 /// <param name="firstname">Initial value of the Firstname property.</param>
 /// <param name="lastname">Initial value of the Lastname property.</param>
 /// <param name="address">Initial value of the Address property.</param>
 /// <param name="town">Initial value of the Town property.</param>
 /// <param name="mobile">Initial value of the Mobile property.</param>
 public static User CreateUser(global::System.String username, global::System.String password, global::System.String email, global::System.String pin, global::System.String firstname, global::System.String lastname, global::System.String address, global::System.String town, global::System.Int32 mobile)
 {
     User user = new User();
     user.Username = username;
     user.Password = password;
     user.Email = email;
     user.Pin = pin;
     user.Firstname = firstname;
     user.Lastname = lastname;
     user.Address = address;
     user.Town = town;
     user.Mobile = mobile;
     return user;
 }
예제 #32
0
 public static byte[] CharacterLoadout(User.Client client)
 {
     PacketWriter packet = new PacketWriter();
     packet.WriteOpcode(SendOps.WorldSelect); //  0B 00 00 00 01 00 03 00 00 00 00 00 00 00 D0 5E CD 01 D0 CF E2 DD
     packet.WriteByte(0);
     packet.WriteByte(client.Characters.Count);
     foreach (Character chr in client.Characters)
     {
        AddCharacterEntry(packet, chr);
     }
     //packet.WriteHexString("6E B9 79 00 6D 65 72 63 65 64 65 73 65 77 00 00 00 00 0C 4D 50 00 00 AD 82 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 D2 07 0C 00 05 00 04 00 04 00 32 00 00 00 32 00 00 00 05 00 00 00 05 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 70 C9 3F 36 00 00 00 00 00 00 00 00 05 A2 ED 77 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 02 00 00 00 00 68 95 CC 02 F0 FB D7 0D 0B 3B 37 4F 01 00 40 E0 FD 00 0C 4D 50 00 00 D2 07 00 00 00 AD 82 00 00 05 50 06 10 00 07 87 5D 10 00 0B 76 39 17 00 37 20 E2 11 00 FF FF 00 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 01 22 7F 27 00 BB 05 00 00 94 4E 00 00 39 00 00 00 6F B9 79 00 6D 65 72 63 65 64 65 73 65 75 00 00 00 00 0C 45 50 00 00 AD 82 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 D2 07 0C 00 05 00 04 00 04 00 32 00 00 00 32 00 00 00 05 00 00 00 05 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 70 C9 3F 36 00 DB 01 00 00 00 00 00 05 A2 ED 77 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 02 00 00 00 00 00 00 00 00 58 04 00 00 BD 7D 20 CD 01 D0 54 06 40 00 0C 45 50 00 00 D2 07 00 00 00 AD 82 00 00 05 50 06 10 00 07 87 5D 10 00 0B 76 39 17 00 37 20 E2 11 00 FF FF 00 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 01 22 7F 27 00 BB 05 00 00 94 4E 00 00 39 00 00 00");
     packet.WriteByte(1); // second password set
     packet.WriteByte(0); // ?
     packet.WriteInt(3); // character slots
     packet.WriteInt(0); // ``click-here'' cash shop slots. overwrites free character slots, however the location vector is wrong.
     return packet.ToArray();
 }
예제 #33
0
    public void MainStudentView()
    {
        System.Diagnostics.Debug.WriteLine("entered mainStudent view:" + Server.HtmlEncode(Request.Cookies["daisySession"]["session"]));
        if (Request.Cookies["daisySession"] != null && Server.HtmlEncode(Request.Cookies["daisySession"]["session"]) != "-1")
        {
            sessionId = Convert.ToInt32(Server.HtmlEncode(Request.Cookies["daisySession"]["session"]));
            System.Diagnostics.Debug.WriteLine("Sessionid:" + sessionId);
            Common.User user = client.GetUser(sessionId);
            //set header content of page
            HtmlGenericControl newHeadInner = new HtmlGenericControl("p");
            newHeadInner.InnerHtml = "Welcome <span>" + user.Firstname + " " + user.Lastname + "</span>, you are logged in as a student";
            HtmlGenericControl newHeader = new HtmlGenericControl("div");
            newHeader.Attributes.Add("class", "headerInfo");
            newHeader.Controls.Add(newHeadInner);
            headerInfo.Controls.Add(newHeader);

            //Set main content of page
            System.Collections.Generic.List <Course> userCourses = client.getCourses(sessionId);
            foreach (Course course in userCourses)
            {
                Common.GradedCourse graded = client.GetCourseGrade(user.Id, course.Id);
                String grade = graded.GradeName;
                if (String.IsNullOrEmpty(grade))
                {
                    grade = "n/a";
                }

                HtmlGenericControl newInner = new HtmlGenericControl("p");
                newInner.Attributes.Add("class", "centerMainCourse");
                newInner.InnerHtml = "<span>Course</span>: " + course.Code + " " + " - " + course.Name + " <span class=\"studentGrade\">  Grade: <span class=\"studentGrade1\">" + grade + "</span></span>";

                HtmlGenericControl newCource = new HtmlGenericControl("div");
                newCource.Attributes.Add("class", "studentInfo");
                newCource.Controls.Add(newInner);

                HtmlGenericControl newGrades = new HtmlGenericControl("div");
                newGrades.Attributes.Add("class", "courseGrades");
                newGrades.Attributes.Add("display", "none");

                System.Collections.Generic.List <TaskGroup> taskgroup = client.GetTaskGroups(course.Id);
                foreach (GradedTaskGroup tg in graded.GradedTaskGroups)
                {
                    HtmlGenericControl newInnerTg = new HtmlGenericControl("div");
                    newInnerTg.Attributes.Add("class", "innertaskgroup");

                    HtmlGenericControl newInnerTgH = new HtmlGenericControl("h4");
                    newInnerTgH.InnerHtml = tg.TaskGroup.Name + "<span> - " + tg.GradeName + "</span>";
                    newInnerTg.Controls.Add(newInnerTgH);

                    System.Collections.Generic.List <Task> task = client.GetTasks(tg.TaskGroup.Id);
                    foreach (Task cTask in task)
                    {
                        HtmlGenericControl newInnerTask = new HtmlGenericControl("p");
                        newInnerTask.InnerHtml = " - " + cTask.Name;
                        newInnerTg.Controls.Add(newInnerTask);
                    }
                    newGrades.Controls.Add(newInnerTg);
                }
                courses.Controls.Add(newCource);
                courses.Controls.Add(newGrades);
            }
        }
        else
        {
            Response.Redirect("Login.aspx", true);
        }
    }
 public UserChangedEventArgs(User user)
 {
     User = user;
 }
예제 #35
0
        public async Task <IHttpActionResult> Register(UserModel model)
        {
            if (!ModelState.IsValid)
            {
                return(Ok(new MessageData(false, "实体数据验证错误", ModelState)));
            }
            string encryptPassword        = string.Empty;
            string encryptPasswordComfirm = string.Empty;

            try
            {
                encryptPassword        = EncryptionHelper.Base64_Decode(model.Password);
                encryptPasswordComfirm = EncryptionHelper.Base64_Decode(model.Password);
            }
            catch (Exception ex)
            {
                return(Ok(new MessageData(false, "用户名或秘密不正确")));
            }

            if (!encryptPassword.Equals(encryptPasswordComfirm))
            {
                return(Ok(new MessageData(false, "密码和确定密码不一致")));
            }
            if (encryptPassword.Length < 6 || encryptPasswordComfirm.Length < 6)
            {
                return(Ok(new MessageData(false, "请输入至少6位数的密码")));
            }
            if (_userService.PhoneNumberIsExists(model.PhoneNumber.Trim()))
            {
                return(Ok(new MessageData(false, "改手机号已存在")));
            }

            IdentityResult result;
            JObject        resObj;

            var user = new Common.User();

            user.TrueName    = string.Empty;
            user.UserName    = model.PhoneNumber;
            user.Password    = encryptPassword;
            user.PhoneNumber = model.PhoneNumber;
            user.Description = string.Empty;
            user.UserType    = UserType.Customer;
            user.IsDelete    = false;
            user.CreateTime  = DateTime.Now;

            //创建用户
            result = await _userService.CreateAsync(user, encryptPassword);

            if (result.Succeeded)
            {
                result = await _userService.AddToRolesAsync(user.Id, "客户");
            }
            if (!result.Succeeded)
            {
                IHttpActionResult errorResult = GetErrorResult(result);
                if (errorResult != null)
                {
                    return(errorResult);
                }
            }
            resObj = GenerateLocalAccessTokenResponse(model.PhoneNumber);//生成用户返回信息tokne和过期时间etc

            return(Ok(new MessageData(true, "注册成功", resObj)));
        }
예제 #36
0
 /// <summary>
 /// Create a new User object.
 /// </summary>
 /// <param name="id">Initial value of the ID property.</param>
 /// <param name="name">Initial value of the Name property.</param>
 /// <param name="surname">Initial value of the Surname property.</param>
 /// <param name="email">Initial value of the Email property.</param>
 /// <param name="mobile">Initial value of the Mobile property.</param>
 /// <param name="residenceName">Initial value of the ResidenceName property.</param>
 /// <param name="streetName">Initial value of the StreetName property.</param>
 /// <param name="townID">Initial value of the TownID property.</param>
 /// <param name="accountID">Initial value of the AccountID property.</param>
 public static User CreateUser(global::System.Int32 id, global::System.String name, global::System.String surname, global::System.String email, global::System.Int32 mobile, global::System.String residenceName, global::System.String streetName, global::System.Int32 townID, global::System.Int32 accountID)
 {
     User user = new User();
     user.ID = id;
     user.Name = name;
     user.Surname = surname;
     user.Email = email;
     user.Mobile = mobile;
     user.ResidenceName = residenceName;
     user.StreetName = streetName;
     user.TownID = townID;
     user.AccountID = accountID;
     return user;
 }
예제 #37
0
 public void Given_the_User_(User User)
 {
 }
예제 #38
0
 public PrivateChat(Socket socket, Common.User item)
 {
     this.User   = item;
     this.Socket = socket;
     InitializeComponent();
 }
 /// <summary>
 /// Create a new User object.
 /// </summary>
 /// <param name="id">Initial value of the Id property.</param>
 /// <param name="name">Initial value of the Name property.</param>
 /// <param name="surname">Initial value of the Surname property.</param>
 /// <param name="email">Initial value of the Email property.</param>
 /// <param name="postcode">Initial value of the Postcode property.</param>
 /// <param name="streetAddress">Initial value of the StreetAddress property.</param>
 /// <param name="dateOfBirth">Initial value of the DateOfBirth property.</param>
 /// <param name="townFK">Initial value of the TownFK property.</param>
 /// <param name="userDetailsFK">Initial value of the UserDetailsFK property.</param>
 /// <param name="userTypeFK">Initial value of the UserTypeFK property.</param>
 public static User CreateUser(global::System.Guid id, global::System.String name, global::System.String surname, global::System.String email, global::System.String postcode, global::System.String streetAddress, global::System.DateTime dateOfBirth, global::System.Int32 townFK, global::System.Guid userDetailsFK, global::System.Int32 userTypeFK)
 {
     User user = new User();
     user.Id = id;
     user.Name = name;
     user.Surname = surname;
     user.Email = email;
     user.Postcode = postcode;
     user.StreetAddress = streetAddress;
     user.DateOfBirth = dateOfBirth;
     user.TownFK = townFK;
     user.UserDetailsFK = userDetailsFK;
     user.UserTypeFK = userTypeFK;
     return user;
 }