Example #1
0
 public ViewResult Edit(UserModel um)
 {
     if (!TryUpdateModel(um))
     {
         ViewModel.updateError = "Update Failure";
         return View(um);
     }
     // ToDo: add persistent to DB.
     BusinessLogic.UserManagerServiceAdaptor sa = new BusinessLogic.UserManagerServiceAdaptor();
     Entities.User u = new Entities.User();
     u.FirstName = um.FirstName;
     u.LastName = um.LastName;
     sa.Update(u);
     //_usrs.Update(um);
     return View("Details", um);
 }
        /// <summary>
        ///     Add user to the user collection.
        /// </summary>
        /// <param name="model">An instance of the user class.</param>
        /// <returns>True if the registration succeeds; otherwise, false.</returns>
        public bool Create(User model)
        {
            try
            {
                _userRepository.Add(model);

                _auditTrailRepository.Log($"{model.Username}", AuditActionEnum.Created);

                _log.Info("Registered user");

                return true;
            }
            catch (MongoConnectionException ex)
            {
                _log.Error("Mongodb", ex);
                return false;
            }
            catch (Exception ex)
            {
                _log.Error("Others", ex);
                return false;
            }
        }
 public bool Edit(User model)
 {
     throw new NotImplementedException();
 }
Example #4
0
        private void btnAddUser_Click(object sender, EventArgs e)
        {
            // AU - Add User

            var username = tboUsernameAU.Text;
            var passwword = tboPasswordAU.Text;
            var fullName = tboFullNameAU.Text;

            if (!string.IsNullOrWhiteSpace(username) && !string.IsNullOrWhiteSpace(passwword) &&
                !string.IsNullOrWhiteSpace(fullName))
            {
                var user = new User
                {
                    FullName = fullName,
                    PasswordHash = Utilities.GetPasswordHash(passwword),
                    Username = username,
                    TimeStamp = DateTime.UtcNow
                };

                var success = _userRepository.Create(user);

                if (success)
                {
                    MessageBox.Show($"User \"{username}\" has been registered", @"School Accountant");
                    ClearTextBoxesAU();
                }
                else
                {
                    MessageBox.Show(@"Something went wrong, please restart the program and try again", @"School Accountant");
                }
            }

            else
            {

                MessageBox.Show(@"Please, all information are required", @"School Accountant");
            }
        }