Exemplo n.º 1
0
        public UserManagerResult HesapAktiveEt(Guid activeGuid)
        {
            UserManagerResult res = new UserManagerResult();

            res.User = unitOfWork.Repository <VotedressUser>().Find(x => x.ActivateGuid == activeGuid);

            if (res.User != null)
            {
                if (res.User.IsActive)
                {
                    res.AddError(ErrorMessageCode.UserAlreadyActive, "Bu hesap zaten aktif");
                    return(res);
                }
                else
                {
                    res.User.IsActive = true;
                    unitOfWork.Repository <VotedressUser>().Update(res.User);
                }
            }
            else
            {
                res.AddError(ErrorMessageCode.ActivateIdDoesNotExists, "Bu aktive kodu geçersiz");
            }
            return(res);
        }
Exemplo n.º 2
0
        public UserManagerResult GirisKontrol(Giris kullanici)
        {
            UserManagerResult res = new UserManagerResult();

            res.User = unitOfWork.Repository <VotedressUser>().Find(x => x.Email == kullanici.Email && x.Password == kullanici.Password);

            List <VotedressUser> k = new List <VotedressUser>();

            if (res.User != null)
            {
                if (res.User.IsActive != true)
                {
                    res.AddError(ErrorMessageCode.UserIsNotActive, "Bu hesap aktifleştirlmemiş Lütfen mail adresinizi kontrol ediniz");
                    res.HataNerece.Add("yukarida");
                }
            }
            else
            {
                res.AddError(ErrorMessageCode.UsernameOrPassWrong, "Kullanıcı adı veya şifre uyuşmuyor");
                res.HataNerece.Add("yukarida");
            }
            return(res);
        }
Exemplo n.º 3
0
        public UserManagerResult KurumsalKullaniciKayit(KurumsalHesapKayit kullanici)
        {
            UserManagerResult res = new UserManagerResult();

            VotedressUser kayitli_kullanici  = EmailKontrol(kullanici.Email);
            UserDetail    kurumsal_kullanici = TcnoKontrol(kullanici.Tcno);

            int kontrol = 0;

            if (kayitli_kullanici != null)
            {
                res.AddError(ErrorMessageCode.UserNameAlreadyExists, "Bu email zaten kayıtlı."); // Daha farklı hatalarda olsaydı onuda listeye eklicegimiz için list türünde yaptık
                res.HataNerece.Add("KurumsalHesap.Email");
                kontrol = 1;
            }

            if (kurumsal_kullanici != null)
            {
                res.AddError(ErrorMessageCode.TcnoAlreadyExists, "Bu TC numarası kayitli"); // Daha farklı hatalarda olsaydı onuda listeye eklicegimiz için list türünde yaptık
                res.HataNerece.Add("KurumsalHesap.Tcno");
                kontrol = 1;
            }
            if (kontrol != 1)
            {
                Guid id = Guid.NewGuid();

                VotedressUser user = new VotedressUser()
                {
                    id           = id,
                    Email        = kullanici.Email,
                    ActivateGuid = Guid.NewGuid(),
                    CreateDate   = DateTime.Now,
                    Password     = kullanici.Sifre,
                    Role         = "kurumsal",
                    ProfileImage = null,
                    SocialId     = null,
                    SocialName   = "votedress",
                    IsActive     = false,
                };


                City il = new City();

                int cityId = int.Parse(kullanici.Il);
                il = unitOfWork.Repository <City>().Find(x => x.CityID == cityId);

                County ilce     = new County();
                int    countyID = int.Parse(kullanici.Ilce);
                ilce = unitOfWork.Repository <County>().Find(x => x.CountyID == countyID);

                Neighborhood mahalle        = new Neighborhood();
                int          NeighborhoodID = int.Parse(kullanici.Mahalle);
                mahalle = unitOfWork.Repository <Neighborhood>().Find(x => x.NeighborhoodID == NeighborhoodID);


                UserDetail UserDetail = new UserDetail()
                {
                    UserId          = id,
                    Name            = kullanici.Ad,
                    SurName         = kullanici.Soyad,
                    City            = il,
                    County          = ilce,
                    Neighborhood    = mahalle,
                    AdressDetail    = kullanici.Adresdetayi,
                    CommencialTitle = kullanici.Ticariunvan,
                    LandPhone       = kullanici.Sabitno,
                    PhoneNumber     = kullanici.Ceptelefonno,
                    TcNo            = kullanici.Tcno,
                    TypeOfBusiness  = kullanici.Isletmeturu,
                    Birthday        = null,
                    Sex             = null,
                    User            = user
                };


                unitOfWork.Repository <VotedressUser>().Insert(user);
                int dbResult = unitOfWork.SaveChanges();


                unitOfWork.Repository <UserDetail>().Insert(UserDetail);
                dbResult = +unitOfWork.SaveChanges();



                if (dbResult > 2)
                {
                    res.User       = unitOfWork.Repository <VotedressUser>().Find(x => x.Email == kullanici.Email);
                    res.UserDetail = unitOfWork.Repository <UserDetail>().Find(x => x.UserId == res.User.id);


                    MailHelper MailGonder = new MailHelper();

                    string siteUri      = ConfigHelper.Get <string>("SiteRootUri");
                    string activateGuid = $"{siteUri}/Account/HesapAktive/{res.User.ActivateGuid}";

                    string body = $"Hesabınızı aktifleştirmek için <a href='{activateGuid}' target='_blank'> tıklayınız.</a>";

                    MailGonder.SendMail(body, res.User.Email, "Votedress Hesap Aktifleştirme");
                }
            }
            return(res);
        }
Exemplo n.º 4
0
        public UserManagerResult BireyselKullaniciKayit(BireyselHesapKayit kullanici)
        {
            UserManagerResult res = new UserManagerResult();

            VotedressUser kayitli_kullanici = EmailKontrol(kullanici.Email);

            if (kayitli_kullanici != null)
            {
                res.AddError(ErrorMessageCode.UserNameAlreadyExists, "Bu email zaten kayıtlı."); // Daha farklı hatalarda olsaydı onuda listeye eklicegimiz için list türünde yaptık
                res.HataNerece.Add("BireyselHesap.Email");
            }

            else
            {
                Guid id = Guid.NewGuid();

                VotedressUser user = new VotedressUser()
                {
                    id           = id,
                    Email        = kullanici.Email,
                    ActivateGuid = Guid.NewGuid(),
                    CreateDate   = DateTime.Now,
                    Password     = kullanici.Sifre,
                    Role         = "bireysel",
                    ProfileImage = "/Content/img/profil_resmi.png",
                    SocialId     = null,
                    SocialName   = "votedress",
                    IsActive     = false,
                };


                UserDetail UserDetail = new UserDetail()
                {
                    UserId       = id,
                    Birthday     = kullanici.DogumTarihi,
                    Name         = kullanici.Ad,
                    SurName      = kullanici.Soyad,
                    Sex          = kullanici.Cinsiyet,
                    City         = null,
                    Neighborhood = null,
                    County       = null,
                    User         = user,
                };

                unitOfWork.Repository <VotedressUser>().Insert(user);
                int dbResult = unitOfWork.SaveChanges();

                unitOfWork.Repository <UserDetail>().Insert(UserDetail);
                dbResult = +unitOfWork.SaveChanges();


                if (dbResult > 0)
                {
                    res.User = unitOfWork.Repository <VotedressUser>().Find(x => x.Email == kullanici.Email);


                    MailHelper MailGonder = new MailHelper();

                    string siteUri      = ConfigHelper.Get <string>("SiteRootUri");
                    string activateGuid = $"{siteUri}/Account/HesapAktive/{res.User.ActivateGuid}";

                    string body = $"Hesabınızı aktifleştirmek için <a href='{activateGuid}' target='_blank'> tıklayınız.</a>";

                    MailGonder.SendMail(body, res.User.Email, "Votedress Hesap Aktifleştirme");
                }
            }

            return(res);
        }