public BusinessLayerResult <KeepITUser> ActivateUser(Guid activateId)
        {
            BusinessLayerResult <KeepITUser> res = new BusinessLayerResult <KeepITUser>();

            res.Result = repo_user.Find(x => x.ActivateGuid == activateId);

            if (res.Result != null)
            {
                if (res.Result.IsActive)
                {
                    res.AddError(ErrorMessageCodes.UserAlreadyActive, "Kullanıcı zaten aktif edilmiştir.");
                    return(res);
                }
                res.Result.IsActive = true;
                repo_user.Update(res.Result);
            }
            else
            {
                res.AddError(ErrorMessageCodes.InvalidActivateId, "Aktifleştirilecek kullanıcı bulunamadı.");
            }
            return(res);
        }
        public BusinessLayerResult <KeepITUser> UpdateProfile(KeepITUser data)
        {
            KeepITUser db_user = repo_user.Find(x => x.Id != data.Id && (x.Username == data.Username || x.Email == data.Email));
            BusinessLayerResult <KeepITUser> res = new BusinessLayerResult <KeepITUser>();

            if (db_user != null && db_user.Id != data.Id)
            {
                if (db_user.Username == data.Username)
                {
                    res.AddError(ErrorMessageCodes.UsernameAlreadyExists, "Kullanıcı adı kayıtlı.");
                }

                if (db_user.Email == data.Email)
                {
                    res.AddError(ErrorMessageCodes.EmailAlreadyExists, "E-posta adresi kayıtlı.");
                }
                return(res);
            }

            res.Result          = repo_user.Find(x => x.Id == data.Id);
            res.Result.Email    = data.Email;
            res.Result.Name     = data.Name;
            res.Result.Surname  = data.Surname;
            res.Result.Password = data.Password;
            res.Result.Username = data.Username;

            if (string.IsNullOrEmpty(data.ProfilePhotoPath) == false)
            {
                res.Result.ProfilePhotoPath = data.ProfilePhotoPath;
            }

            if (repo_user.Update(res.Result) == 0)
            {
                res.AddError(ErrorMessageCodes.ProfileCouldNotUpdated, "Profil güncellenemedi.");
            }

            return(res);
        }
        public BusinessLayerResult <KeepITUser> LoginUser(LoginViewModel data)
        {
            // Giriş kontrolü
            // Hesap aktive edilmiş mi
            BusinessLayerResult <KeepITUser> res = new BusinessLayerResult <KeepITUser>();

            res.Result = repo_user.Find(x => (x.Username == data.Username && x.Password == data.Password) || (x.Email == data.Username && x.Password == data.Password));


            if (res.Result != null)
            {
                if (!res.Result.IsActive)
                {
                    res.AddError(ErrorMessageCodes.UserIsNotActive, "Kullanıcı aktif değil.");
                    res.AddError(ErrorMessageCodes.CheckYourEmail, "Lütfen mailinizi kontrol ediniz.");
                }
            }
            else
            {
                res.AddError(ErrorMessageCodes.UsernameOrPassWrong, "Kullanıcı adı veya şifre hatalı");
            }

            return(res);
        }