public ActionResult SohbetGecmisi(string AliciId, string GondericiId) { MsgHistViewModel Gorusme = new MsgHistViewModel(); if (AliciId == null || GondericiId == null) { Gorusme.Baslik = "Görüntülenecek mesaj bulunamadı"; } else { Gorusme.AliciId = AliciId; Gorusme.GondericiId = GondericiId; var usermanager = IdentityTools.NewUserManager(); var Arkadas = usermanager.FindById(AliciId); Gorusme.Baslik = Arkadas.Name + " ile olan mesaj geçmişin"; List <Gorusmeler> TumKonusmalari = ent.Gorusmeler.Where(m => (m.AliciId == AliciId || m.GondericiId == AliciId) && (m.AliciId == GondericiId || m.GondericiId == GondericiId)).OrderBy(me => me.Tarih).ToList(); List <MsgModel> Mesajlar = new List <MsgModel>(); foreach (var konusma in TumKonusmalari) { MsgModel Mesaj = new MsgModel(); Mesaj.AliciId = konusma.AliciId; Mesaj.GondericiId = konusma.GondericiId; Mesaj.Tarih = konusma.Tarih; Mesaj.Mesaj = konusma.Mesaj; Mesajlar.Add(Mesaj); } Gorusme.Mesajlar = Mesajlar; } return(PartialView(Gorusme)); }
public ActionResult GetExams() { var usermanager = IdentityTools.NewUserManager(); var uid = usermanager.FindByName(User.Identity.Name); int StdId = SrRepo.Get(s => s.UserId == uid.Id).Id; GetMyExamsViewModel myExams = new GetMyExamsViewModel(); myExams.evaluations = EvRepo.GetAll(e => e.IsDeleted == false && e.StudentId == StdId).ToList(); List <Exam> AllExam = ExRepo.GetAll(e => e.IsDeleted == false).ToList(); myExams.exams = new List <Exam>(); foreach (Evaluation item in myExams.evaluations) { foreach (Exam ex in AllExam) { if (item.ExamId == ex.Id) { myExams.exams.Add(ex); } } } return(View(myExams)); }
public ActionResult Edit(UserListViewModel model) { var usermanager = IdentityTools.NewUserManager(); ApplicationUser Degisecek = (from u in ent.Users where u.Id == model.Id select u).FirstOrDefault(); if (model.Role != usermanager.GetRoles(model.Id)[0]) { usermanager.RemoveFromRole(Degisecek.Id, usermanager.GetRoles(model.Id)[0]); usermanager.AddToRole(model.Id, model.Role); } try { Degisecek.Name = model.Name; Degisecek.Surname = model.Surname; Degisecek.UserName = model.UserName; Degisecek.PhoneNumber = model.PhoneNumber; Degisecek.Email = model.Email; ent.SaveChanges(); } catch (Exception ex) { string message = ex.Message; return(RedirectToAction("Edit", model)); } return(RedirectToAction("UserOperations")); }
public ActionResult Login(LoginViewModel model) { if (!ModelState.IsValid) { return(View(model)); } var usermanager = IdentityTools.NewUserManager(); var kullanici = usermanager.FindByName(model.Username); if (kullanici == null) { ModelState.AddModelError("", "Böyle bir kullanıcı kayıtlı değil!"); return(View(model)); } else { if (!usermanager.CheckPassword(kullanici, model.Password)) { ModelState.AddModelError("", "Girilen şifre yanlış!"); return(View(model)); } else { var authManager = HttpContext.GetOwinContext().Authentication; var identity = usermanager.CreateIdentity(kullanici, "ApplicationCookie"); var authProperty = new AuthenticationProperties { IsPersistent = model.RememberMe }; authManager.SignIn(authProperty, identity); return(Redirect(string.IsNullOrEmpty(model.returnUrl) ? "/" : model.returnUrl)); } } }
public JsonResult Register(RegisterViewModel model) { List <string> errors = new List <string>(); if (string.IsNullOrEmpty(model.Password)) { errors = ModelState.Values.SelectMany(state => state.Errors).Select(error => error.ErrorMessage).ToList(); return(Json(errors, JsonRequestBehavior.AllowGet)); } if (model.Password.Count() < 8) { ModelState.AddModelError("", "Şifre en az 8 karakter uzunluğunda olmalıdır!"); errors = ModelState.Values.SelectMany(state => state.Errors).Select(error => error.ErrorMessage).ToList(); return(Json(errors, JsonRequestBehavior.AllowGet)); } if (!ModelState.IsValid) { errors = ModelState.Values.SelectMany(state => state.Errors).Select(error => error.ErrorMessage).ToList(); return(Json(errors, JsonRequestBehavior.AllowGet)); } var usermanager = IdentityTools.NewUserManager(); var kullanici = usermanager.FindByEmail(model.Email); if (kullanici != null) { ModelState.AddModelError("", "Bu E-Posta Sistemde Kayıtlı!"); errors = ModelState.Values.SelectMany(state => state.Errors).Select(error => error.ErrorMessage).ToList(); return(Json(errors, JsonRequestBehavior.AllowGet)); } ApplicationUser user = new ApplicationUser(); user.Name = model.Name; user.Surname = model.Surname; user.Email = model.Email; user.UserName = model.Email; user.DogumTarihi = model.DogumTarihi; var result = usermanager.Create(user, model.Password); if (result.Succeeded) { usermanager.AddToRole(user.Id, "User"); var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = "" }, protocol: Request.Url.Scheme); IdentityMessage msg = new IdentityMessage(); msg.Destination = user.Email; msg.Body = "Nerdeyse tamamlandı! NeYapsak ağına katılmak için <a href=\"" + callbackUrl + "\">neyapsak</a> linkine tıkla."; msg.Subject = "NeYapsak Hesap Doğrulama Servisi"; mail.SendMail(msg); errors = ModelState.Values.SelectMany(state => state.Errors).Select(error => error.ErrorMessage).ToList(); return(Json("True", JsonRequestBehavior.AllowGet)); } else { foreach (var error in result.Errors) { ModelState.AddModelError(string.Empty, error); } } errors = ModelState.Values.SelectMany(state => state.Errors).Select(error => error.ErrorMessage).ToList(); return(Json(errors, JsonRequestBehavior.AllowGet)); }
public JsonResult AddorUpdateExam(AllExamViewModel model) { var usermanager = IdentityTools.NewUserManager(); var uid = usermanager.FindByName(User.Identity.Name); Teacher t = TrRepo.Get(x => x.UserId == uid.Id); bool result = false; if (model.Id == 0) { Exam ex = new Exam(); ex.ExamName = model.ExamName; ex.ClassId = model.ClassId; ex.TeacherId = t.Id; ex.StartDate = model.StartDate; ex.Description = model.Description; result = ExRepo.Add(ex); } else { Exam uex = ExRepo.Get(a => a.Id == model.Id); uex.ExamName = model.ExamName; uex.ClassId = model.ClassId; uex.TeacherId = t.Id; uex.Description = model.Description; result = ExRepo.Update(uex); } return(Json(result, JsonRequestBehavior.AllowGet)); }
public ActionResult Login(string username, string password) { var usermanager = IdentityTools.NewUserManager(); var kullanici = usermanager.FindByEmail(username); if (kullanici == null) { ModelState.AddModelError("", " *Böyle bir kullanıcı kayıtlı değil!"); return(View()); } else { if (!usermanager.CheckPassword(kullanici, password)) { ModelState.AddModelError("", " *Şifre Hatalı!"); return(View()); } var authManager = HttpContext.GetOwinContext().Authentication; var identity = usermanager.CreateIdentity(kullanici, "ApplicationCookie"); var authProperty = new AuthenticationProperties { IsPersistent = false }; authManager.SignIn(authProperty, identity); return(RedirectToAction("Index", "Home")); } }
public ActionResult Index() { MsgBoxViewModel model = new MsgBoxViewModel(); string Gonderici = HttpContext.User.Identity.GetUserId(); model.UserId = Gonderici; var GecmisSohbetGiden = ent.Gorusmeler.Where(g => g.GondericiId == Gonderici).Select(go => go.AliciId).Distinct().ToList(); var usermanager = IdentityTools.NewUserManager(); List <ApplicationUser> Kullanicilar = new List <ApplicationUser>(); foreach (var id in GecmisSohbetGiden) { var kullanici = usermanager.FindById(id); Kullanicilar.Add(kullanici); } var GecmisSohbetGelen = ent.Gorusmeler.Where(g => g.AliciId == Gonderici).Select(go => go.GondericiId).Distinct().ToList(); foreach (var id in GecmisSohbetGelen) { var kullanici = usermanager.FindById(id); if (Kullanicilar.Contains(kullanici)) { continue; } else { Kullanicilar.Add(kullanici); } } model.Kullanicilar = Kullanicilar.Reverse <ApplicationUser>().ToList(); //güncel konuşmanın geçmiş listesinde başa gelmesi için. return(View(model)); }
public ActionResult Login(LoginViewModel model) { if (!ModelState.IsValid) //Model ile gelen verinin Validation kontrolü { return(View(model)); } var usermanager = IdentityTools.NewUserManager(); ApplicationUser kullanici = usermanager.FindByEmail(model.Email); if (kullanici == null) //Email sistemde kayıtlımı kontrolü { ModelState.AddModelError("", "Böyle bir kullanıcı kayıtlı değil!"); return(View(model)); } else if (!usermanager.CheckPassword(kullanici, model.Password)) //Şifre kontrolü { ModelState.AddModelError("", "Bilgilerinizi kontrol ediniz!"); return(View(model)); } else { var role = usermanager.GetRoles(kullanici.Id); var authManager = HttpContext.GetOwinContext().Authentication; var identity = usermanager.CreateIdentity(kullanici, "ApplicationCookie"); var authProperty = new AuthenticationProperties //Authentication işlemleri { IsPersistent = model.RememberMe }; authManager.SignIn(authProperty, identity); Session["User"] = kullanici.Name; return(Redirect(string.IsNullOrEmpty(model.returnUrl) ? "/" : model.returnUrl)); } }
public JsonResult StudentUpdate(StudentUpdateModel model) { var usermanager = IdentityTools.NewUserManager(); bool result = false; Student std = SrRepo.Get(x => x.Id == model.StdId); std.Name = model.Name; std.Surname = model.Surname; std.Adress = model.Adress; std.ClassId = model.ClassId; std.IdentificationNo = model.IdentificationNo; ApplicationUser au = usermanager.FindById(std.UserId); au.Email = model.Email; au.UserName = model.Email; if (SrRepo.Update(std)) { var uresult = usermanager.Update(au); if (uresult.Succeeded) { result = true; } } return(Json(result, JsonRequestBehavior.AllowGet)); }
public ActionResult Register(string userName, string password, string email) { var usermanager = IdentityTools.NewUserManager(); //* //var kullanici = usermanager.FindByName(model.Username); var kullanici = usermanager.FindByEmail(email); if (kullanici != null) { return(Json("Bu emaili kullanamazsınız")); } ApplicationUser user = new ApplicationUser(); user.UserName = userName; user.Email = email; user.PasswordHash = password; var result = usermanager.Create(user, password); if (result.Succeeded) { usermanager.AddToRole(user.Id, "User"); } else { foreach (var error in result.Errors) { //ModelState.AddModelError(string.Empty, error); return(Json("Lütfen türkçe karakter kullanmayın ve alanların tamamını doldurunuz")); } } return(Json("Kayıt Tamamlandı")); }
public ActionResult ChangePassword(PasswordChangeViewModel model) { var usermanager = IdentityTools.NewUserManager(); var kullanici = usermanager.FindById(HttpContext.User.Identity.GetUserId()); if (!ModelState.IsValid) { return(View(model)); } else if (!usermanager.CheckPassword(kullanici, model.OldPassword)) { ModelState.AddModelError("", "Mevcut şifren bu değil!"); return(View(model)); } var result = usermanager.ChangePassword(kullanici.Id, model.OldPassword, model.NewPassword); if (result.Succeeded) { IdentityMessage msg = new IdentityMessage(); msg.Subject = "Şifren değiştirildi!"; msg.Destination = kullanici.Email; msg.Body = "Merhaba " + kullanici.Name + " az önce sitemiz üzerinden bir şifre yenileme işlemi gerçekleştirdin. Yeni şifreni sitemize bol bol giriş yaparak iyi günlerde kullanmanı dileriz."; mail.SendMail(msg); HttpContext.GetOwinContext().Authentication.SignOut(); return(View("PasswordResetSuccess")); } else { return(View("Error")); } }
public ActionResult PasswordReset(string userId, string email, string code) { if (userId == null || email == null || code == null) { return(View("Error")); } var usermanager = IdentityTools.NewUserManager(); var kullanici = usermanager.FindByEmail(email); if (kullanici == null) { return(View("Error")); } else { if (kullanici.Id != userId) { return(View("Error")); } else { if (!UserManager.VerifyUserTokenAsync(kullanici.Id, "ResetPassword", code).Result) { return(View("Error")); } else { PasswordResetViewModel model = new PasswordResetViewModel(); model.Email = email; model.Code = code; return(View("PasswordReset", model)); } } } }
public ActionResult OnlineExams() { var usermanager = IdentityTools.NewUserManager(); var uid = usermanager.FindByName(User.Identity.Name); AllExamViewModel Aev = new AllExamViewModel(); Aev.exams = ExRepo.GetAll(e => e.Teacher.UserId == uid.Id && e.IsDeleted == false && e.Description == "Online").ToList(); return(View(Aev)); }
public ActionResult Profiles() { var usermanager = IdentityTools.NewUserManager(); var uid = usermanager.FindByName(User.Identity.Name); ProfileViewModel model = new ProfileViewModel(); model.Shares = ArRepo.GetAll(a => a.UserId == uid.Id).OrderByDescending(a => a.CreatedDate).ToList(); return(View(model)); }
public ActionResult RollCalls() { var usermanager = IdentityTools.NewUserManager(); var uid = usermanager.FindByName(User.Identity.Name); int StdId = SrRepo.Get(s => s.UserId == uid.Id).Id; List <RollCall> rollCalls = new List <RollCall>(); rollCalls = RrRepo.GetAll(r => r.StudentId == StdId).ToList(); return(View(rollCalls)); }
// GET: Academical public ActionResult Index() { var usermanager = IdentityTools.NewUserManager(); var uid = usermanager.FindByName(User.Identity.Name); TeacherIndexModel tim = new TeacherIndexModel(); tim.Classrooms = CrRepo.GetAll(c => c.IsDeleted == false && c.Teacher.UserId == uid.Id).ToList(); tim.Announcements = AnRepo.GetAll(a => a.IsDeleted == false && a.Teacher.UserId == uid.Id).ToList(); return(View(tim)); }
public ActionResult OnlineExams() { var usermanager = IdentityTools.NewUserManager(); var uid = usermanager.FindByName(User.Identity.Name); Student std = SrRepo.Get(s => s.UserId == uid.Id); AllExamViewModel aev = new AllExamViewModel(); aev.exams = ExRepo.GetAll(e => e.ClassId == std.ClassId && e.IsDeleted == false && e.Description == "Online").ToList(); aev.Evaluations = EvRepo.GetAll(e => e.StudentId == std.Id && e.IsDeleted == false).ToList(); return(View(aev)); }
public ActionResult AddQuestions(int ClassId, int ExamId) { var usermanager = IdentityTools.NewUserManager(); var uid = usermanager.FindByName(User.Identity.Name); AddQuestionViewModel aqm = new AddQuestionViewModel(); aqm.Questions = QrRepo.GetAll(q => q.IsDeleted == false && q.ExamId == ExamId).ToList(); aqm.ExamId = ExamId; aqm.ClassId = ClassId; return(View(aqm)); }
//public JsonResult GetAnnouncementById(int ID) //{ // Announcement ann = AnRepo.Get(a => a.Id == ID && a.IsDeleted==false); // return Json(ann,JsonRequestBehavior.AllowGet); //} public ActionResult Announcement() { var usermanager = IdentityTools.NewUserManager(); var uid = usermanager.FindByName(User.Identity.Name); AnnouncementModel anm = new AnnouncementModel(); anm.AnList = AnRepo.GetAll(a => a.IsDeleted == false && a.Teacher.UserId == uid.Id).ToList(); anm.AnTList = AntRepo.GetAll(a => a.IsDeleted == false).ToList(); anm.TeacherId = TrRepo.Get(t => t.IsDeleted == false && t.UserId == uid.Id).Id; return(View(anm)); }
public ActionResult Forum() { var usermanager = IdentityTools.NewUserManager(); var uid = usermanager.FindByName(User.Identity.Name); int ClassId = SrRepo.Get(s => s.UserId == uid.Id).ClassId; ForumViewModel fvm = new ForumViewModel(); fvm.Shares = ArRepo.GetAll(s => s.ClassId == ClassId && s.IsDeleted == false).OrderByDescending(a => a.CreatedDate).ToList(); fvm.UserId = uid.Id; return(View(fvm)); }
public ActionResult OtherProfileAdmin(UserViewModel model) { if (model.Kullanici.Id != null) { Repository <ApplicationUser> repoU = new Repository <ApplicationUser>(new NeYapsakContext()); Repository <Ilan> repoIlan = new Repository <Ilan>(new NeYapsakContext()); Repository <Katilan> repoKat = new Repository <Katilan>(new NeYapsakContext()); UserViewModel usermodel = new UserViewModel(); if (model.PictureUpload != null) { //string name = Path.GetFileNameWithoutExtension(model.PictureUpload.FileName); //string ext = Path.GetExtension(model.PictureUpload.FileName); ////Resim upload edilecek. //name = name.Replace(" ", ""); string filename = model.PictureUpload.FileName; string imagePath = Server.MapPath("/images/" + filename); model.PictureUpload.SaveAs(imagePath); ApplicationUser degisen = repoU.GetAll().Where(u => u.Id == model.Kullanici.Id).FirstOrDefault(); degisen.ProfilAvatarYolu = "/images/" + filename; if (repoU.Update(degisen)) { return(Redirect("/Home/OtherProfileAdmin/" + model.Kullanici.Id)); } return(View(model)); } var usermanager = IdentityTools.NewUserManager(); var kullanici = usermanager.FindByEmail(model.Kullanici.Email); kullanici.Name = model.Kullanici.Name; kullanici.Surname = model.Kullanici.Surname; kullanici.Email = model.Kullanici.Email; kullanici.DogumTarihi = model.Kullanici.DogumTarihi; kullanici.Bio = model.Kullanici.Bio; usermanager.Update(kullanici); usermodel.Kullanici = kullanici; usermodel.KullaniciIlanlari = repoIlan.GetAll().Where(i => i.KullaniciId == model.Kullanici.Id).ToList(); usermodel.IlgilendigiIlanlar = repoKat.GetAll().Where(k => k.KullaniciId == model.Kullanici.Id && k.Onay == false && k.Silindi == false).Select(k => k.Ilan).Distinct().ToList(); usermodel.KatildigiIlanlar = repoKat.GetAll().Where(k => k.KullaniciId == model.Kullanici.Id && k.Onay == true && k.Silindi == false).Select(k => k.Ilan).Distinct().ToList(); usermodel.OnayimiBekleyenIlanlar = repoKat.GetAll().Where(k => k.Onay == false && k.Silindi == false).Select(k => k.Ilan).Distinct().Where(i => i.KullaniciId == model.Kullanici.Id && i.Silindi == false).ToList(); usermodel.OnayladigimIlanlar = repoKat.GetAll().Where(k => k.Onay == true && k.Silindi == false).Select(k => k.Ilan).Distinct().Where(i => i.KullaniciId == model.Kullanici.Id && i.Silindi == false).ToList(); return(View(usermodel)); } return(Redirect("/Home/Main")); }
public JsonResult Sharing(Article model) { var usermanager = IdentityTools.NewUserManager(); var uid = usermanager.FindByName(User.Identity.Name); bool result = false; Article ar = new Article(); ar.Content = model.Content; ar.UserId = uid.Id; result = ArRepo.Add(ar); return(Json(result, JsonRequestBehavior.AllowGet)); }
protected void Application_Start() { using (BlogContext ent = new BlogContext()) { ent.Database.CreateIfNotExists(); } var usermanager = IdentityTools.NewUserManager(); var rolemanager = IdentityTools.NewRoleManager(); if (usermanager.FindByName("*****@*****.**") == null) { try { ApplicationUser AppUserAdmin = new ApplicationUser() { Name = "Serkan", Surname = "Karışan", Email = "*****@*****.**", UserName = "******", EmailConfirmed = true, SecurityStamp = "d6b253a0-6325-410b-bed4-796ba916e443", PhoneNumber = "5355063330", PhoneNumberConfirmed = true, TwoFactorEnabled = false, LockoutEndDateUtc = null, LockoutEnabled = false, AccessFailedCount = 0 }; IdentityResult result = usermanager.Create(AppUserAdmin, "123Qw."); if (result.Succeeded) { if (rolemanager.FindByName("Admin") != null) { ApplicationRole Rol = rolemanager.FindByName("Admin"); var currentUser = usermanager.FindByName(AppUserAdmin.UserName); usermanager.AddToRole(currentUser.Id, "Admin"); } else { ApplicationRole appRole = new ApplicationRole(); appRole.Name = "Admin"; rolemanager.Create(appRole); var currentUser = usermanager.FindByName(AppUserAdmin.UserName); usermanager.AddToRole(currentUser.Id, "Admin"); } if (rolemanager.FindByName("User") == null) { ApplicationRole appRole = new ApplicationRole(); appRole.Name = "User"; rolemanager.Create(appRole); } } } catch (Exception ex) { string hata = ex.Message; throw; } } AreaRegistration.RegisterAllAreas(); FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); RouteConfig.RegisterRoutes(RouteTable.Routes); BundleConfig.RegisterBundles(BundleTable.Bundles); }
// GET: Student public ActionResult Index() { var usermanager = IdentityTools.NewUserManager(); var uid = usermanager.FindByName(User.Identity.Name); int ClassId = SrRepo.Get(s => s.UserId == uid.Id).ClassId; AllAnnouncements AllAnn = new AllAnnouncements(); AllAnn.ClassAnn = AnRepo.GetAll(a => a.ClassId == ClassId && a.IsDeleted == false && a.TypeId == 2).ToList(); AllAnn.GeneralAnn = AnRepo.GetAll(a => a.IsDeleted == false && a.TypeId == 1).ToList(); return(View(AllAnn)); }
public ActionResult MyProfile() { var usermanager = IdentityTools.NewUserManager(); var uid = usermanager.FindByName(User.Identity.Name); int ClassId = SrRepo.Get(s => s.UserId == uid.Id).ClassId; ProfileViewModel model = new ProfileViewModel(); model.Sinifim = SrRepo.GetAll(s => s.ClassId == ClassId && s.IsDeleted == false && s.UserId != uid.Id).ToList(); model.Shares = ArRepo.GetAll(a => a.UserId == uid.Id && a.IsDeleted == false).OrderByDescending(a => a.CreatedDate).ToList(); model.MyUserId = uid.Id; model.Bio = BrRepo.Get(b => b.UserId == uid.Id); return(View(model)); }
public JsonResult Login(LoginViewModel model) { List <string> errors = new List <string>(); if (!ModelState.IsValid) { errors = ModelState.Values.SelectMany(state => state.Errors).Select(error => error.ErrorMessage).ToList(); return(Json(errors, JsonRequestBehavior.AllowGet)); } var usermanager = IdentityTools.NewUserManager(); var kullanici = usermanager.FindByName(model.Email); if (kullanici == null) { ModelState.AddModelError("", "Böyle bir kullanıcı kayıtlı değil!"); errors = ModelState.Values.SelectMany(state => state.Errors).Select(error => error.ErrorMessage).ToList(); return(Json(errors, JsonRequestBehavior.AllowGet)); } else { if (!usermanager.CheckPassword(kullanici, model.Password)) { ModelState.AddModelError("", "Girilen şifre yanlış!"); errors = ModelState.Values.SelectMany(state => state.Errors).Select(error => error.ErrorMessage).ToList(); return(Json(errors, JsonRequestBehavior.AllowGet)); } else { if (kullanici.EmailConfirmed) { var authManager = HttpContext.GetOwinContext().Authentication; var identity = usermanager.CreateIdentity(kullanici, "ApplicationCookie"); var authProperty = new AuthenticationProperties { IsPersistent = model.RememberMe }; authManager.SignIn(authProperty, identity); return(Json("True", JsonRequestBehavior.AllowGet)); } else { List <string> errores = new List <string>(); errores.Add("E-Posta doğrulamasını yapman gerekmektedir!"); errores.Add("Doğrulama linkim gelmedi diyorsan "); errores.Add(kullanici.Id); errores.Add("tıklayabilirsin."); return(Json(errores, JsonRequestBehavior.AllowGet)); } } } }
public ActionResult Register(RegisterViewModel model) { if (!ModelState.IsValid)//Model ile gelen verinin Validation kontrolü { return(View(model)); } var usermanager = IdentityTools.NewUserManager(); var kullanici = usermanager.FindByEmail(model.Email); if (kullanici != null)//Email sistemde kayıtlımı kontrolü { ModelState.AddModelError("", "Bu email sistemde kayıtlı!"); return(View(model)); } ApplicationUser user = new ApplicationUser(); user.Name = model.Name; user.Surname = model.Surname; user.Email = model.Email; user.UserName = model.Username; if (model.PictureUpload == null)// Kullanıcı resim eklemezse Default resim ataması { user.UserPicture = "avatar.png"; } else {//Resimin Database ve İmages klasörüne yazılması string filename = model.PictureUpload.FileName; string imagePath = Server.MapPath("/images/" + filename); model.PictureUpload.SaveAs(imagePath); user.UserPicture = filename; } var result = usermanager.Create(user, model.Password);//User Kaydı if (result.Succeeded) { // usermanager.AddToRole(user.Id, "User"); istendiğinde rol eklenebilir return(RedirectToAction("Login")); } else { foreach (var error in result.Errors) { ModelState.AddModelError(string.Empty, error); } } return(View(model)); }
public ActionResult GetBIO() { var usermanager = IdentityTools.NewUserManager(); var uid = usermanager.FindByName(User.Identity.Name); Biography bio = new Biography(); bio = BrRepo.Get(x => x.UserId == uid.Id); string value = string.Empty; value = JsonConvert.SerializeObject(bio, Formatting.Indented, new JsonSerializerSettings { ReferenceLoopHandling = ReferenceLoopHandling.Ignore }); return(Json(value, JsonRequestBehavior.AllowGet)); }
public JsonResult BonusUpdate() { var usermanager = IdentityTools.NewUserManager(); //aktif kullanici ApplicationUser appuser = usermanager.FindByName(User.Identity.Name); var bonus = repoBonus.GetAll(x => x.UserId == appuser.Id && x.IsDeleted == false && x.BonusName == "+ Saniye").OrderBy(x => x.date).Take(1); foreach (var item in bonus) { item.IsDeleted = true; } bool result = repoBonus.Update(); return(Json(result, JsonRequestBehavior.AllowGet)); }