Esempio n. 1
0
        public async Task <IActionResult> StudentRegister(StudentRegisterCO 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         = true,
                YetkiId       = (int)Yetkiler.STUDENT,
                Resim         = path
            };
            var userId = _kullaniciService.Create(user);

            return(RedirectToAction("Login", "Account"));
        }