Пример #1
0
 /// <summary>
 /// Инициализация по имени
 /// </summary>
 /// <param name="email">имя пользователя [email]</param>
 public void Init(string email, IRepository repository)
 {
     if (!string.IsNullOrEmpty(email))
     {
         User = repository.GetUser(email);
     }
 }
Пример #2
0
        public bool CreateUser(User instance) {
            if (instance.ID != 0) {
                return false;
            }
            instance.AddedDate = DateTime.Now;
            instance.ActivatedLink = User.GetActivateUrl();

            Db.Users.InsertOnSubmit(instance);
            Db.Users.Context.SubmitChanges();
            return true;
        }
Пример #3
0
        public bool UpdateUser(User instance) {
            var cache = Db.Users.FirstOrDefault(p => p.ID == instance.ID);
            if (cache == null) {
                return false;
            }
            cache.AvatarPath = instance.AvatarPath;
            cache.Email = instance.Email;

            Db.Users.Context.SubmitChanges();
            return true;
        }
Пример #4
0
 public bool UpdateUser(User instance)
 {
     User cache = Db.Users.Where(p => p.ID == instance.ID).FirstOrDefault();
     if (cache != null)
     {
         cache.Birthdate = instance.Birthdate;
         cache.AvatarPath = instance.AvatarPath;
         cache.Email = instance.Email;
         Db.Users.Context.SubmitChanges();
         return true;
     }
     return false;
 }
Пример #5
0
        public bool ChangeLanguage(User instance, string LangCode)
        {
            var cache = Db.Users.FirstOrDefault(p => p.ID == instance.ID);
            var newLang = Db.Languages.FirstOrDefault(p => p.Code == LangCode);
            if (cache != null && newLang != null)
            {
                cache.Language = newLang;
                Db.Users.Context.SubmitChanges();
                return true;
            }

            return false;
        }
Пример #6
0
        public void GenerateUsers()
        {
            Users = new List<User>();

            var admin = new User()
            {
                ID = 1,
                ActivatedDate = DateTime.Now,
                ActivatedLink = "",
                Email = "admin",
                Password = "******",
                LastVisitDate = DateTime.Now,
            };

            var role = Roles.First(p => p.Code == "admin");
            var userRole = new UserRole()
            {
                User = admin,
                UserID = admin.ID,
                Role = role,
                RoleID = role.ID
            };

            admin.UserRoles =
                new EntitySet<UserRole>() {
                    userRole
                };
            Users.Add(admin);

            Users.Add(new User()
            {
                ID = 2,
                ActivatedDate = DateTime.Now,
                ActivatedLink = "",
                Email = "*****@*****.**",
                Password = "******",
                LastVisitDate = DateTime.Now
            });

            this.Setup(p => p.Users).Returns(Users.AsQueryable());
            this.Setup(p => p.GetUser(It.IsAny<string>())).Returns((string email) =>
                Users.FirstOrDefault(p => string.Compare(p.Email, email, 0) == 0));
            this.Setup(p => p.Login(It.IsAny<string>(), It.IsAny<string>())).Returns((string email, string password) =>
                Users.FirstOrDefault(p => string.Compare(p.Email, email, 0) == 0));
        }
Пример #7
0
 partial void DeleteUser(User instance);
Пример #8
0
 partial void UpdateUser(User instance);
Пример #9
0
 partial void InsertUser(User instance);
		private void detach_Users(User entity)
		{
			this.SendPropertyChanging();
			entity.Language = null;
		}
		private void attach_Users(User entity)
		{
			this.SendPropertyChanging();
			entity.Language = this;
		}