Пример #1
0
 public static User Map(AuthorViewModel viewModel)
 {
     User user = new User();
     user.Id = viewModel.Id;
     user.Email = viewModel.Email;
     user.FirstName = viewModel.FirstName;
     user.LastName = viewModel.LastName;
     return user;
 }
Пример #2
0
 public static AuthorViewModel Map(User user)
 {
     AuthorViewModel viewModel = new AuthorViewModel();
     viewModel.Id = user.Id;
     viewModel.Email = user.Email;
     viewModel.FirstName = user.FirstName;
     viewModel.LastName = user.LastName;
     return viewModel;
 }
Пример #3
0
 public void Register(User user, string password)
 {
     if (!dataContext.UserStorage.Exists(user.Email))
     {
         user.LastAccessDate = DateTime.Now;
         user.RegistrationDate = DateTime.Now;
         dataContext.UserStorage.Add(user);
         RegisterNewUser(user, password);
     }
 }
Пример #4
0
 public static User Map(RegistrationViewModel viewModel)
 {
     User user = new User();
     user.Email = viewModel.Email;
     user.FirstName = viewModel.FirstName;
     user.LastName = viewModel.LastName;
     user.University = viewModel.University;
     user.BirthDate = DateMapper.Map(viewModel.BirthDate);
     user.PhotoFileName = viewModel.PhotoFileName;
     return user;
 }
Пример #5
0
 public void Update(User user)
 {
     Entities.Database.ExecuteSqlCommand(
         UpdateUserQuery,
         user.Email,
         user.FirstName,
         user.LastName,
         user.University,
         user.BirthDate,
         user.LastAccessDate,
         user.PhotoFileName,
         user.Id);
 }
Пример #6
0
 private void RegisterNewUser(User user, string password)
 {
     try
     {
         roleManager.AddUserToRole(user.Email, UserRole);
         accountManager.CreateAccount(user.Email, password);
     }
     catch (SecurityCreateUserException)
     {
         dataContext.UserStorage.Remove(user.Email);
         throw;
     }
 }
Пример #7
0
 public static User Map(UserViewModel viewModel)
 {
     User user = new User();
     user.Id = viewModel.Id;
     user.Email = viewModel.Email;
     user.FirstName = viewModel.FirstName;
     user.LastName = viewModel.LastName;
     user.BirthDate = DateMapper.Map(viewModel.BirthDate);
     user.PhotoFileName = viewModel.PhotoFile != null
         ? viewModel.PhotoFile.FileName
         : viewModel.PhotoFileName;
     user.University = viewModel.University;
     return user;
 }
Пример #8
0
 public static UserViewModel Map(User user)
 {
     UserViewModel viewModel = new UserViewModel();
     viewModel.Id = user.Id;
     viewModel.Email = user.Email;
     viewModel.FirstName = user.FirstName;
     viewModel.LastName = user.LastName;
     viewModel.University = user.University;
     viewModel.BirthDate = DateMapper.Map(user.BirthDate);
     viewModel.PhotoFileName = user.PhotoFileName;
     if (user.Disciplines != null)
     {
         viewModel.Disciplines = user.Disciplines.Select(DisciplineMapper.Map);
     }
     return viewModel;
 }
Пример #9
0
 public void Update(User user)
 {
     Account.Update(user);
 }
Пример #10
0
 public void Register(User user, string password)
 {
     Account.Register(user, password);
 }
Пример #11
0
 public void Add(User user)
 {
     Add(user, Entities.Users);
 }
Пример #12
0
 //TODO: move to separate class
 public void Update(User user)
 {
     user.LastAccessDate = DateTime.Now;
     dataContext.UserStorage.Update(user);
 }
Пример #13
0
        private void CreateUser(string userFile)
        {
            string userInfo = File.ReadAllText(userFile);
            var user = new User();
            user.Email = GetInfoField(userInfo, "email");
            user.FirstName = GetInfoField(userInfo, "first_name");
            user.LastName = GetInfoField(userInfo, "last_name");
            user.University = GetInfoField(userInfo, "university");

            user.BirthDate = DateTime.Parse(GetInfoField(userInfo, "date"));
            user.PhotoFileName = "0.jpg";
            string passwrod = GetInfoField(userInfo, "password");
            service.Register(user, passwrod);
            string[] disciplines = GetInfoField(userInfo, "disciplines").Split(',');
            service.Subscribe(user.Id, GetDisciplines(disciplines));
            if (!Regex.IsMatch(userFile, "\\d"))
            {
                roleManager.AddUserToRole(user.Email, "Admin");
            }
        }