示例#1
0
 public static void Register(string name, string password)
 {
     if (Global.business.UserExists(name))
     {
         throw new Exception("User with that name already exists in a database");
     }
     AccountDM account = new AccountDM() { Name = name, Password = CalculateMD5Hash(password)};
     Global.business.CreateUser(Mapper.Map<User>(account));
 }
示例#2
0
        public static void Register(string name, string password)
        {
            if (Global.business.UserExists(name))
            {
                throw new Exception("User with that name already exists in a database");
            }
            AccountDM account = new AccountDM()
            {
                Name = name, Password = CalculateMD5Hash(password)
            };

            Global.business.CreateUser(Mapper.Map <User>(account));
        }
示例#3
0
        public static List <NoteDM> GetAll(NoteFilter filter)
        {
            List <NoteDM> notes = GetAll();

            if (filter.MinDate != default(DateTime))
            {
                notes = notes.Where(n => n.CreationDate >= filter.MinDate).ToList();
            }
            if (filter.MaxDate != default(DateTime))
            {
                notes = notes.Where(n => n.CreationDate <= filter.MaxDate).ToList();
            }
            if (!string.IsNullOrWhiteSpace(filter.Authors))
            {
                string[] authors = filter.Authors.Split(';');
                notes = notes.Where(n => authors.Any(a => a == AccountDM.GetUserName(n.Author))).ToList();
            }
            if (!string.IsNullOrWhiteSpace(filter.LikedBy))
            {
                string[] likedBy = filter.LikedBy.Split(';');
                notes = notes.Where(n => likedBy.Any(a => NoteDM.IsLiked(AccountDM.GetUserId(a), n.Id))).ToList();
            }
            return(notes);
        }