public bool Register()
        {
            List<User> users = new List<User>();
            bool accountCreated = false;
            string _password = EncryptDecryptPassword.CalculateToMD5Hash((registrationHeader._password));
            bool isLoginAllowed = true;

            using (var dB = new DailyServerContext())
            {
                users = dB.UserSet.ToList();

                foreach (var user in users)
                {
                    if (user.Login.Trim() == registrationHeader._login)
                    {
                        isLoginAllowed = false;
                    }
                }

                if (isLoginAllowed)
                {
                    var newUser = new User()
                    {
                        Name = registrationHeader._name,
                        Surname = registrationHeader._surname,
                        BirthDay = registrationHeader._birthDay.Date,
                        Sex = registrationHeader._sex,
                        AboutMe = registrationHeader._aboutMe,
                        LastActivity = DateTime.Now,
                        Login = registrationHeader._login,
                        Password = _password.Trim(),
                        eMail = registrationHeader._eMail,
                    };
                    dB.UserSet.Add(newUser);
                    dB.SaveChanges();

                    var newUserTarget = new UserTarget()
                    {
                        Date = registrationHeader._targetDate.Date,
                        Weight = registrationHeader._targetWeight,
                        BodyFat = registrationHeader._targetBodyFat,
                        User = newUser,
                    };
                    dB.UserTargetSet.Add(newUserTarget);
                    dB.SaveChanges();

                    accountCreated = true;
                }
            }
            return accountCreated;
        }
 public UserHelper Login()
 {
     List<User> user = new List<User>();
     UserHelper loginUser = new UserHelper();
     UserTarget userTarget = new UserTarget();
     try
     {
         using (var dB = new DailyServerContext())
         {
             user = dB.UserSet.ToList();
             for (int i = 0; i < user.Count; i++)
             {
                 if (user[i].Login.Trim() == authenticationHeader._login &&
                     EncryptDecryptPassword.VerifyMd5Hash(authenticationHeader._password, user[i].Password.Trim()))
                 {
                     loginUser.UserId = user[i].UserId;
                     loginUser.Name = user[i].Name;
                     loginUser.Surname = user[i].Surname;
                     loginUser.BirthDay = user[i].BirthDay;
                     loginUser.Sex = user[i].Sex;
                     loginUser.AboutMe = user[i].AboutMe;
                     loginUser.LastActivity = user[i].LastActivity;
                     user[i].LastActivity = DateTime.Now;
                     loginUser.Login = user[i].Login;
                     loginUser.Password = user[i].Password;
                     loginUser.eMail = user[i].eMail;
                     break;
                 }
             }
             dB.SaveChanges();
         }
         return loginUser;
     }
     catch (Exception)
     {
         return new UserHelper();
     }
 }