示例#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");
            }
        }