public ActionResult DeleteConfirmed(int id) { ShareYourNoteUser shareYourNoteUser = _userManager.Find(x => x.Id == id); _userManager.Delete(shareYourNoteUser); return(RedirectToAction("Index")); }
public ActionResult Edit(ShareYourNoteUser shareYourNoteUser) { BusinessResult <ShareYourNoteUser> result = _userManager.Update(shareYourNoteUser); //TODO : Düzenle if (result.Errors.Count > 0) { result.Errors.ForEach(x => ModelState.AddModelError("", x.Messages)); return(View(shareYourNoteUser)); } return(View(shareYourNoteUser)); }
public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } ShareYourNoteUser shareYourNoteUser = _userManager.Find(x => x.Id == id); if (shareYourNoteUser == null) { return(HttpNotFound()); } return(View(shareYourNoteUser)); }
public ActionResult Create(ShareYourNoteUser shareYourNoteUser) { if (ModelState.IsValid) { BusinessResult <ShareYourNoteUser> result = _userManager.Insert(shareYourNoteUser); //TODO : Düzenle if (result.Errors.Count > 0) { result.Errors.ForEach(x => ModelState.AddModelError("", x.Messages)); return(View(shareYourNoteUser)); } return(RedirectToAction("Index")); } return(View(shareYourNoteUser)); }
public ActionResult EditProfile(ShareYourNoteUser model, HttpPostedFileBase ProfileImage) { if (ModelState.IsValid) { if (ProfileImage != null && ( ProfileImage.ContentType == "image/jpeg" || ProfileImage.ContentType == "image/jpg" || ProfileImage.ContentType == "image/png" )) { string fileName = $"user_{model.Id}.{ProfileImage.ContentType.Split('/')[1]}"; ProfileImage.SaveAs(Server.MapPath($"~/UploadedFiles/ProfileImages/{fileName}")); model.ProfilePhotoName = fileName; } BusinessResult <ShareYourNoteUser> result = um.UpdateProfile(model); if (result.Errors.Count > 0) { ErrorViewModel notifyObject = new ErrorViewModel() { Title = "Profil güncellenemedi..", Items = result.Errors, RedirectingUrl = "/Home/EditProfile" }; return(View("Error", notifyObject)); } SessionManager.Set <ShareYourNoteUser>("login", result.Result); return(RedirectToAction("ShowProfile")); } return(View(model)); }
protected override void Seed(DataContext context) { ShareYourNoteUser admin = new ShareYourNoteUser() { Name = "Ersin", Surname = "Devrim", ActivateGuid = Guid.NewGuid(), IsActive = true, ProfilePhotoName = "defaultImage.png", IsAdmin = true, Username = "******", Password = "******", Email = "*****@*****.**" }; ShareYourNoteUser standartUser = new ShareYourNoteUser() { Name = "Birkan", Surname = "Köse", Email = "*****@*****.**", ProfilePhotoName = "defaultImage.png", ActivateGuid = Guid.NewGuid(), IsAdmin = false, IsActive = true, Username = "******", Password = "******" }; context.ShareYourNoteUsers.Add(admin); context.ShareYourNoteUsers.Add(standartUser); for (int i = 0; i < 8; i++) { ShareYourNoteUser shareYourNoteUsertUser = new ShareYourNoteUser() { Name = FakeData.NameData.GetFirstName(), Surname = FakeData.NameData.GetSurname(), Email = FakeData.NetworkData.GetEmail(), ProfilePhotoName = "defaultImage.png", ActivateGuid = Guid.NewGuid(), IsAdmin = false, IsActive = true, Username = $"user{i}", Password = "******" }; context.ShareYourNoteUsers.Add(shareYourNoteUsertUser); } context.SaveChanges(); List <ShareYourNoteUser> userList = context.ShareYourNoteUsers.ToList(); //Fake Schools for (int i = 0; i < 10; i++) { School school = new School() { Name = FakeData.PlaceData.GetStreetName() + " Universitesi", IsApproved = true }; context.Schools.Add(school); //fake Teachers for (int j = 0; j < FakeData.NumberData.GetNumber(2, 10); j++) { Teacher teacher = new Teacher() { Name = FakeData.NameData.GetFullName(), IsApproved = true, School = school, }; school.Teachers.Add(teacher); //fake notes for (int k = 0; k < FakeData.NumberData.GetNumber(3, 5); k++) { ShareYourNoteUser shareYourNoteUser = userList[FakeData.NumberData.GetNumber(0, userList.Count - 1)]; Note note = new Note() { Title = FakeData.TextData.GetAlphabetical(FakeData.NumberData.GetNumber(5, 25)), Description = FakeData.TextData.GetSentences(FakeData.NumberData.GetNumber(1, 3)), IsApproved = true, Owner = shareYourNoteUser, UploadDate = FakeData.DateTimeData.GetDatetime(DateTime.Now.AddYears(-1), DateTime.Now), UploadedFile = "test.pdf" //TODO: School ID mevzusunu çöz. //ÇÖZÜLDÜ }; teacher.Notes.Add(note); //fake comments for (int l = 0; l < FakeData.NumberData.GetNumber(1, 3); l++) { ShareYourNoteUser commentOwner = userList[FakeData.NumberData.GetNumber(0, userList.Count - 1)]; Comment comment = new Comment() { Text = FakeData.TextData.GetSentence(), Owner = commentOwner }; note.Comments.Add(comment); } } } } context.SaveChanges(); }