Beispiel #1
0
            public KullaniciDTO Denetle(string UserId, string sifre)
            {
                Kullanicilar kullanici = null;

                kullanici = Bul(UserId);
                if (kullanici != null)
                {
                    if (kullanici.Sifre == sifre)
                    {
                        KullaniciDTO kullaniciDTO = new KullaniciDTO();
                        kullaniciDTO.UserId    = kullanici.UserId;
                        kullaniciDTO.RolAd     = kullanici.Roller.RolAd;
                        kullaniciDTO.CalisanAd = kullanici.Calisanlar.CalisanAd + " " + kullanici.Calisanlar.CalisanSoyad;
                        return(kullaniciDTO);
                    }
                    else
                    {
                        return(null);
                    }
                }
                else
                {
                    return(null);
                }
            }
Beispiel #2
0
        public int Update(KullaniciDTO dto)
        {
            var entity = ModelMapper.Mapper.Map <Kullanici>(dto);

            entity.EntityState = EntityState.Modified;
            return(_kullaniciRepository.Save(entity));
        }
        public List <KullaniciDTO> MapAll(List <Kullanici> model)
        {
            var kullanicilar = new List <KullaniciDTO>();

            foreach (var ent in model.ToList())
            {
                var kullanici = new KullaniciDTO();
                kullanici.acikAdres   = ent.KullaniciBilgileri.acikAdres;
                kullanici.adi         = ent.KullaniciBilgileri.adi;
                kullanici.cinsiyet    = ent.KullaniciBilgileri.cinsiyet;
                kullanici.dogumTarihi = ent.KullaniciBilgileri.dogumTarihi;
                kullanici.ilAdi       = ent.KullaniciBilgileri.Il.ilAdi;
                kullanici.ilceAdi     = ent.KullaniciBilgileri.Ilce.ilceAdi;
                kullanici.ilceID      = ent.KullaniciBilgileri.ilceID;
                kullanici.ilID        = ent.KullaniciBilgileri.ilID;
                kullanici.kullaniID   = ent.kullaniciID;
                kullanici.soyadi      = ent.KullaniciBilgileri.soyadi;
                kullanici.rolID       = (int)ent.rolID;
                kullanici.email       = ent.KullaniciBilgileri.email;
                kullanici.TCKN        = ent.TCKN;
                kullanici.sifre       = ent.sifre;
                kullanici.rol         = ent.Rol.rolAdi;
                kullanici.telNo       = ent.KullaniciBilgileri.cepTelefonu;

                kullanicilar.Add(kullanici);
            }
            return(kullanicilar);
        }
Beispiel #4
0
        public IHttpActionResult Update(KullaniciDTO model)
        {
            KullaniciBLL kullaniciBusiness = new KullaniciBLL();

            kullaniciBusiness.Update(model);
            return(Ok());
        }
Beispiel #5
0
        public KullaniciDTO GetById(int id)
        {
            using (KullaniciRepository kullaniciRepo = new KullaniciRepository())
            {
                try
                {
                    var ent          = kullaniciRepo.GetById(id);
                    var kullanicidto = new KullaniciDTO();

                    kullanicidto.adi         = ent.adi;
                    kullanicidto.kullaniciID = ent.kullaniciID;
                    kullanicidto.password    = ent.password;
                    kullanicidto.rol         = ent.Rol.rol1;
                    kullanicidto.rolID       = ent.rolID;
                    kullanicidto.sirketAdi   = ent.Sirket.sirketAdi;
                    kullanicidto.sirketID    = ent.sirketID;
                    kullanicidto.soyadi      = ent.soyadi;
                    kullanicidto.username    = ent.username;

                    return(kullanicidto);
                }
                catch (Exception ex)
                {
                    throw;
                }
            }
        }
Beispiel #6
0
        public List <KullaniciDTO> Get(int sirketId)
        {
            using (KullaniciRepository kullaniciRepo = new KullaniciRepository())
            {
                try
                {
                    var model        = kullaniciRepo.Get();
                    var Kullanicilar = new List <KullaniciDTO>();
                    foreach (var ent in model.ToList())
                    {
                        if (ent.rolID == 1 && ent.sirketID == sirketId)
                        {
                            var kullanicidto = new KullaniciDTO();
                            kullanicidto.adi         = ent.adi;
                            kullanicidto.kullaniciID = ent.kullaniciID;
                            kullanicidto.password    = ent.password;
                            kullanicidto.rol         = ent.Rol.rol1;
                            kullanicidto.rolID       = ent.rolID;
                            kullanicidto.sirketAdi   = ent.Sirket.sirketAdi;
                            kullanicidto.sirketID    = ent.sirketID;
                            kullanicidto.soyadi      = ent.soyadi;
                            kullanicidto.username    = ent.username;

                            Kullanicilar.Add(kullanicidto);
                        }
                    }
                    return(Kullanicilar);
                }
                catch (Exception ex)
                {
                    throw;
                }
            }
        }
Beispiel #7
0
        public async Task <IActionResult> Edit(KullaniciDTO model, IFormFile file)
        {
            var user = _kullaniciService.GetById(Convert.ToInt32(User.Claims.Where(c => c.Type == ClaimTypes.Name)
                                                                 .Select(c => c.Value)
                                                                 .SingleOrDefault()));

            if (file != null)
            {
                var webRoot = Path.Combine("Uploads", "Documents");
                var path    = Path.Combine(webRoot, file.FileName);
                using (var stream = new FileStream(path, FileMode.Create))
                {
                    await file.CopyToAsync(stream);
                }
                model.Resim = path;
            }
            else
            {
                model.Resim = user.Resim;
            }

            model.TuzlamaDegeri = user.TuzlamaDegeri;
            model.Sifre         = user.Sifre;
            model.EklenmeZamani = user.EklenmeZamani;
            model.Guid          = user.Guid;
            model.Aktif         = user.Aktif;
            model.Silindi       = user.Silindi;
            model.YetkiId       = user.YetkiId;
            model.Id            = user.Id;

            _kullaniciService.Update(model);

            return(RedirectToAction("GetByUser", new RouteValueDictionary(new { controller = "Account", action = "GetByUser", Model = user })));
        }
Beispiel #8
0
        public int Create(KullaniciDTO dto)
        {
            var entity = ModelMapper.Mapper.Map <Kullanici>(dto);

            entity.Yetki       = null;
            entity.EntityState = EntityState.Added;
            return(_kullaniciRepository.Save(entity));
        }
Beispiel #9
0
        public static KullaniciDTO GetKullaniciDto(Kullanici kullanici)
        {
            KullaniciDTO DTOKullanici = new KullaniciDTO
            {
                Adi    = kullanici.Adi,
                Soyadi = kullanici.Soyadi,
                Email  = kullanici.Email,
                Sifre  = kullanici.Password,
            };

            return(DTOKullanici);
        }
Beispiel #10
0
        public async Task <IActionResult> Login(GirisCO request)
        {
            KullaniciDTO user = _kullaniciService.GetByKullanici(request.Email, request.Sifre);

            if (user == null)
            {
                return(View("Error"));
            }

            var giris = new GirisDTO()
            {
                KullaniciId = user.Id,
                Durum       = true,
                Aktif       = true,
                Silindi     = false
            };
            var girisId = _girisService.Create(giris);

            if (user != null)
            {
                var claims = new List <Claim>
                {
                    new Claim(ClaimTypes.Name, user.Id.ToString()),
                    new Claim(ClaimTypes.NameIdentifier, user.Ad + " " + user.Soyad),
                    new Claim(ClaimTypes.Role, user.YetkiId.ToString())
                };

                var userIdentity = new ClaimsIdentity(claims, "login");

                ClaimsPrincipal principal = new ClaimsPrincipal(userIdentity);
                await HttpContext.SignInAsync(principal);

                if (user.YetkiId == (int)Yetkiler.ADMIN)
                {
                    ViewBag.User = user;
                    return(RedirectToAction("Index", "Admin"));
                }

                if (user.YetkiId == (int)Yetkiler.TEACHER)
                {
                    ViewBag.User = user;
                    return(RedirectToAction("Index", "Home"));
                }

                ViewBag.User = user;
                return(RedirectToAction("Index", "Home"));
            }
            return(View());
        }
        public ResponseModel KullaniciGetir(string request)
        {
            try
            {
                ResponseModel       result = new ResponseModel();
                KullaniciRepository repo   = new KullaniciRepository();
                KullaniciGetirModel model  = JsonConvert.DeserializeObject <KullaniciGetirModel>(request);
                Kullanicilar        user   = repo.GetUserList(x => x.Id == model.KullaniciId);
                KullaniciDTO        dto    = new KullaniciDTO();
                var returnUser             = "";
                if (user != null)
                {
                    dto.Id                 = user.Id;
                    dto.Adi                = user.Adi;
                    dto.Soyadi             = user.Soyadi;
                    dto.Email              = user.Email;
                    dto.Sifre              = user.Sifre;
                    dto.DogumTarihi        = user.DogumTarihi.Value;
                    dto.DiyabetTipi        = user.DiyabetTipi;
                    dto.TeshisKondoguTarih = user.TeshisKonduguTarih.Value;
                    dto.il                 = user.il;
                    dto.ilce               = user.ilce;
                    dto.OlusturmaTarihi    = user.OlusturmaTarihi.Value;


                    returnUser     = JsonConvert.SerializeObject(dto);
                    result.Message = "Success";
                    result.Status  = true;
                    result.Data    = returnUser;

                    return(result);
                }
                else
                {
                    result.Message = "Kullanıcı bulunamadı.";
                    result.Status  = false;
                    result.Data    = null;

                    return(result);
                }
            }
            catch (Exception ex)
            {
                throw;
            }
        }
        public void Add(KullaniciDTO model)
        {
            using (KullaniciRepository kullaniciRepo = new KullaniciRepository())
            {
                try
                {
                    var kullanici = new Kullanici();
                    kullanici.TCKN        = model.TCKN;
                    kullanici.kullaniciID = model.kullaniID;
                    kullanici.rolID       = model.rolID;
                    kullanici.sifre       = model.sifre;
                    kullaniciRepo.Add(kullanici);

                    using (KullaniciBilgileriRepository kullaniciBilRepo = new KullaniciBilgileriRepository())
                    {
                        try
                        {
                            var kulBil = new KullaniciBilgileri();
                            kulBil.acikAdres   = model.acikAdres;
                            kulBil.adi         = model.adi;
                            kulBil.cinsiyet    = model.cinsiyet;
                            kulBil.dogumTarihi = model.dogumTarihi;
                            kulBil.ilceID      = model.ilceID;
                            kulBil.ilID        = model.ilID;
                            kulBil.kullaniciID = kullanici.kullaniciID;
                            kulBil.soyadi      = model.soyadi;
                            kulBil.cepTelefonu = model.telNo;
                            kulBil.email       = model.email;
                            kullaniciBilRepo.Add(kulBil);
                        }
                        catch
                        {
                            throw;
                        }
                    }
                }
                catch
                {
                    throw;
                }
            }
        }
Beispiel #13
0
        public async Task <IActionResult> TeacherRegister(TeacherRegisterCO request, IFormFile file)
        {
            var controlEmail = _kullaniciService.GetByEmail(request.Email);

            if (controlEmail != null)
            {
                return(View("Error"));
            }

            var path = Path.Combine("Uploads", "DefaultPicture", "defaultMan.png");

            if (file != null)
            {
                var webRoot = Path.Combine("Uploads", "Documents");
                path = Path.Combine(webRoot, file.FileName);
                using (var stream = new FileStream(path, FileMode.Create))
                {
                    await file.CopyToAsync(stream);
                }
            }

            var tuzlama = _kullaniciService.GetTuzlamaDegeri();

            var user = new KullaniciDTO()
            {
                Ad            = request.Ad,
                Soyad         = request.Soyad,
                Email         = request.Email,
                KullaniciAdi  = request.KullaniciAdi,
                TuzlamaDegeri = tuzlama,
                Sifre         = _kullaniciService.Sifrele(request.Sifre, tuzlama),
                EklenmeZamani = DateTime.Now,
                Guid          = Guid.NewGuid(),
                Silindi       = false,
                Aktif         = false,
                YetkiId       = (int)Yetkiler.TEACHER,
                Resim         = path
            };
            var userId = _kullaniciService.Create(user);

            return(RedirectToAction("Login", "Account"));
        }
        public KullaniciDTO GetUser(string email, string sifre)
        {
            KullaniciRepository repo    = new KullaniciRepository();
            KullaniciDTO        dtoUser = new KullaniciDTO();
            var user = repo.GetUserList(x => x.Email == email && x.Sifre == sifre);

            if (user != null)
            {
                dtoUser.Id                 = user.Id;
                dtoUser.Adi                = user.Adi;
                dtoUser.Soyadi             = user.Soyadi;
                dtoUser.Sifre              = user.Sifre;
                dtoUser.il                 = user.il;
                dtoUser.ilce               = user.ilce;
                dtoUser.OlusturmaTarihi    = user.OlusturmaTarihi.Value;
                dtoUser.TeshisKondoguTarih = user.TeshisKonduguTarih.Value;
                dtoUser.Email              = user.Email;
                dtoUser.DiyabetTipi        = user.DiyabetTipi;
                dtoUser.Cinsiyet           = user.Cinsiyet;
            }
            return(dtoUser);
        }
        public ActionResult Login(LoginModel m)
        {
            try
            {
                KullaniciManager km           = new KullaniciManager();
                KullaniciDTO     kullaniciDto = km.Denetle(m.Kullanicilar.UserId, m.Kullanicilar.Sifre);
                Session["Kullanici"] = kullaniciDto.UserId;
                Session["Rol"]       = kullaniciDto.RolAd;
                if (Session["Rol"].ToString() == "Admin")
                {
                    return(RedirectToAction("Index", "Home"));
                }

                else
                {
                    return(RedirectToAction("Hata", "Login"));
                }
            }
            catch (Exception)
            {
                return(RedirectToAction("Hata2", "Login"));
            }
        }
        public KullaniciDTO Map(Kullanici ent)
        {
            var kullanici = new KullaniciDTO();

            kullanici.acikAdres   = ent.KullaniciBilgileri.acikAdres;
            kullanici.adi         = ent.KullaniciBilgileri.adi;
            kullanici.cinsiyet    = ent.KullaniciBilgileri.cinsiyet;
            kullanici.dogumTarihi = ent.KullaniciBilgileri.dogumTarihi;
            kullanici.ilAdi       = ent.KullaniciBilgileri.Il.ilAdi;
            kullanici.ilceAdi     = ent.KullaniciBilgileri.Ilce.ilceAdi;
            kullanici.ilceID      = ent.KullaniciBilgileri.ilceID;
            kullanici.ilID        = ent.KullaniciBilgileri.ilID;
            kullanici.kullaniID   = ent.kullaniciID;
            kullanici.soyadi      = ent.KullaniciBilgileri.soyadi;
            kullanici.rolID       = (int)ent.rolID;
            kullanici.email       = ent.KullaniciBilgileri.email;
            kullanici.TCKN        = ent.TCKN;
            kullanici.sifre       = ent.sifre;
            kullanici.rol         = ent.Rol.rolAdi;
            kullanici.telNo       = ent.KullaniciBilgileri.cepTelefonu;


            return(kullanici);
        }
        public ResponseModel Login(string request)
        {
            LoginModel requestModel = JsonConvert.DeserializeObject <LoginModel>(request);

            brokenRules = new StringBuilder();
            ResponseModel result = new ResponseModel();

            var nulCheck = checkEmailandPasswordControl(requestModel.Email, requestModel.Sifre);

            if (nulCheck)
            {
                result.Message = brokenRules.ToString();
                result.Status  = false;
                result.Data    = null;

                return(result);
            }

            KullaniciDTO user = GetUser(requestModel.Email, requestModel.Sifre);

            if (user.Email != null && user.Id > 0)
            {
                var messageAsJson = JsonConvert.SerializeObject(user);

                result.Message = brokenRules.AppendLine("Kullanıcı başarılı bir şekilde giriş yaptı.").ToString();
                result.Status  = true;
                result.Data    = messageAsJson;

                return(result);
            }

            result.Message = brokenRules.AppendLine("Kullanıcı bulunamadı.").ToString();
            result.Status  = false;
            result.Data    = null;
            return(result);
        }
 public int Update(KullaniciDTO kullanici)
 {
     return(_kullaniciRepository.Update(kullanici));
 }
 public int Create(KullaniciDTO dto)
 {
     return(_kullaniciRepository.Create(dto));
 }