public async Task <IActionResult> ChangeEmail(ChangePasswordViewModel model) { if (ModelState.IsValid) { TeacherProfile user = await _userManager.FindByIdAsync(model.Id); if (user != null) { IdentityResult result = await _userManager.ChangePasswordAsync(user, model.OldPassword, model.NewPassword); if (result.Succeeded) { return(RedirectToAction(nameof(Index))); } else { foreach (var error in result.Errors) { ModelState.AddModelError(string.Empty, error.Description); } } } else { ModelState.AddModelError(string.Empty, "Пользователь не найден"); } } return(View(model)); }
//get TeacherProfile Edit on Id public ActionResult EditTeacherProfile(int id) { TeacherProfile teacherProfile = DbHelper.GetTeacher(id); ViewBag.Class = new SelectList(DbHelper.GetClasses(Helper.UserId), "PKClassId", "ClassName", teacherProfile.FKUserId); return(View(DbHelper.GetTeacher(id))); }
public static User ParseFromUserDto(UserDto source) { var invitationList = new List <Invitation>(); var notifiesList = new List <Notification>(); var skillList = new List <string>(); var reviewList = new List <Review>(); var contactList = new List <string>(); source.Invitations?.ForEach(i => invitationList.Add( new Invitation(i.FromUser, i.ToUser, i.GroupId, i.SuggestedRole, i.Status, i.Id))); source.Notifies?.ForEach(n => notifiesList.Add(new Notification(n.OccurredOn, n.NotificationInfo, n.NotificationType))); source.Reviews?.ForEach(r => reviewList.Add(new Review(r.FromUser, r.Title, r.Text, r.FromGroup, r.Id))); source.Tags?.ToList().ForEach(t => skillList.Add(t.Name)); source.Contacts?.ForEach(c => contactList.Add(c.Contact)); var teacherProfile = new TeacherProfile(reviewList, skillList); var userProfile = new UserProfile(source.Name, source.Email, source.AboutUser, source.BirthYear, source.Gender, source.IsTeacher, source.AvatarLink, contactList); var settings = JsonConvert.DeserializeObject <NotificationsSettings>(source.NotificationSettings); var destination = new User(source.Name, new Credentials(source.Email, source.PasswordHash), source.Type, invitationList, teacherProfile, userProfile, source.IsActive, notifiesList, settings, source.Id); return(destination); }
//userComments public async Task <JsonResult> UserComments(string comment, long classId, decimal rating, int teachId) { string userName = Helper.UserName; Task t1 = Task.Run(() => { if (!string.IsNullOrEmpty(comment)) { DbHelper.AddUserComments(new UserComment() { Comments = comment, FKClassId = classId, UserName = userName, Rating = rating }); } }); Task t2 = Task.Run(() => { if (rating != 0) { TeacherProfile objTeacherProfile = new TeacherProfile(); objTeacherProfile = DbHelper.GetTeacher(teachId); objTeacherProfile.Rating = Math.Round((decimal)((objTeacherProfile.Rating + rating) / 2), 1); DbHelper.UpdateTeacherProfile(objTeacherProfile); } }); await Task.WhenAll(t1, t2); return(Json(true)); }
public IHttpActionResult PutTeacherProfile(long id, TeacherProfile teacherProfile) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != teacherProfile.PKTeachersId) { return(BadRequest()); } db.Entry(teacherProfile).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!TeacherProfileExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public async Task <IActionResult> UploadProfilePhoto(IFormFile uploadedFile) { if (uploadedFile != null) { FileManager _fileManager = new FileManager(_context, _appEnvironment); TeacherProfile profile = await GetCurrentuserAsync(); if (profile != null) { if (profile.PhotoId != null) { _fileManager.DeleteFile(profile.Photo); } File photo = _fileManager.SaveFile(uploadedFile); profile.Photo = photo; _context.TeacherProfiles.Update(profile); _context.SaveChanges(); return(View(nameof(Edit), profile)); } } return(RedirectToAction("Index")); }
public async Task <string> NewTeacher(RegisterViewModel model) { //var setting = db.Settings.OrderByDescending(x => x.Id).First(); var user1 = HttpContext.Current.User.Identity.GetUserName(); if (user1 == "SuperAdmin") { user1 = "Admin"; } var user = new ApplicationUser { UserName = model.Username, Surname = model.Surname, Email = model.Email, FirstName = model.FirstName, OtherName = model.OtherName, DateOfBirth = model.DateOfBirth, Religion = model.Religion, PasswordHash = model.Password, //DateRegistered = DateTime.UtcNow, DateRegistered = DateTime.UtcNow.AddHours(1), Phone = model.Phone, ContactAddress = model.ContactAddress, City = model.City, StateOfOrigin = model.StateOfOrigin, Nationality = model.Nationality, RegisteredBy = user1 }; var result = await UserManager.CreateAsync(user, model.Password); if (result.Succeeded) { TeacherProfile teacher = new TeacherProfile(); teacher.UserId = user.Id; teacher.Username = user.UserName; teacher.Surname = user.Surname; teacher.Firstname = user.FirstName; teacher.Fullname = user.Surname + " " + user.FirstName + " " + user.OtherName; teacher.Email = user.Email; teacher.Phone = user.Phone; teacher.DateOfAppointment = DateTime.UtcNow.AddHours(1); db.TeacherProfiles.Add(teacher); await UserManager.AddToRoleAsync(user.Id, "Teacher"); await db.SaveChangesAsync(); var teacherReg = await db.TeacherProfiles.FirstOrDefaultAsync(x => x.UserId == user.Id); teacherReg.StaffRegistrationId = "TEACHER/000" + teacherReg.Id; db.Entry(teacherReg).State = EntityState.Modified; await db.SaveChangesAsync(); return("true"); } var errors = result.Errors; var message = string.Join(", ", errors); return(message); }
public async Task UpdateImageId(int id, int imgId) { TeacherProfile model = await db.TeacherProfiles.FindAsync(id); model.ImageId = imgId; db.Entry(model).State = EntityState.Modified; await db.SaveChangesAsync(); }
public static void InsertTeacherProfile(TeacherProfile objTeacherProfile) { TeachersEntities db = new TeachersEntities(); db.TeacherProfiles.Add(objTeacherProfile); db.SaveChanges(); cache.Remove("GetTeachersHome"); }
public ActionResult CreateTeacherProfile(TeacherProfile objTeacherProfile) { objTeacherProfile.FKClassId = Convert.ToInt64(TempData["ClassId"]); TempData.Keep(); objTeacherProfile.FKUserId = Helper.UserId; objTeacherProfile.IsActive = true; DbHelper.InsertTeacherProfile(objTeacherProfile); return(View("CreateTeacherAvailableTime")); }
public static void DeleteTeacherProfile(int teacherProfileId) { TeachersEntities db = new TeachersEntities(); TeacherProfile objTeacherProfile = db.TeacherProfiles.Find(teacherProfileId); db.TeacherProfiles.Remove(objTeacherProfile); db.SaveChanges(); cache.Remove("GetTeachersHome"); }
private void Teacher_Homepage_Load(object sender, EventArgs e) { TeacherAddExam.Hide(); TeacherCorrectExam.Hide(); TeacherStatistics.Hide(); TeacherClassManagement.Hide(); TeacherCalendar.Hide(); TeacherProfile.Hide(); }
public async Task <TeacherProfile> GetTeacherWithoutId() { var user = HttpContext.Current.User.Identity.GetUserId(); var teacher = await db.TeacherProfiles.Include(x => x.user).FirstOrDefaultAsync(x => x.UserId == user); byte[] c; var img = await db.ImageModel.FirstOrDefaultAsync(x => x.Id == teacher.ImageId); if (img == null) { c = new byte[0]; } else { c = img.ImageContent; } var output = new TeacherProfile { Id = teacher.Id, Disability = teacher.Disability, EmergencyContact = teacher.EmergencyContact, MaritalStatus = teacher.MaritalStatus, StaffRegistrationId = teacher.StaffRegistrationId, DateOfAppointment = teacher.DateOfAppointment, AboutMe = teacher.AboutMe, FavouriteFood = teacher.FavouriteFood, BooksYouLike = teacher.BooksYouLike, MoviesYouLike = teacher.MoviesYouLike, TVShowsYouLike = teacher.TVShowsYouLike, YourLikes = teacher.YourLikes, YourDisLikes = teacher.YourDisLikes, FavouriteColour = teacher.FavouriteColour, Fullname = teacher.user.Surname + " " + teacher.user.FirstName + " " + teacher.user.OtherName, Surname = teacher.user.Surname, Firstname = teacher.user.FirstName, Othername = teacher.user.OtherName, Email = teacher.user.Email, Username = teacher.user.UserName, DateOfBirth = teacher.user.DateOfBirth, DateRegistered = teacher.user.DateRegistered, DataStatusChanged = teacher.user.DataStatusChanged, Religion = teacher.user.Religion, Gender = teacher.user.Gender, ContactAddress = teacher.user.ContactAddress, City = teacher.user.City, Phone = teacher.user.Phone, LocalGov = teacher.user.LocalGov, StateOfOrigin = teacher.user.StateOfOrigin, Nationality = teacher.user.Nationality, RegisteredBy = teacher.user.RegisteredBy, ImageId = teacher.ImageId, Image = c, UserId = teacher.user.Id }; return(output); }
private void btnProfile_Click(object sender, EventArgs e) { TeacherAddExam.Hide(); TeacherCorrectExam.Hide(); TeacherStatistics.Hide(); TeacherClassManagement.Hide(); TeacherCalendar.Hide(); TeacherProfile.Show(); TeacherProfile.BringToFront(); }
public IHttpActionResult GetTeacherProfile(long id) { TeacherProfile teacherProfile = db.TeacherProfiles.Find(id); if (teacherProfile == null) { return(NotFound()); } return(Ok(teacherProfile)); }
public IHttpActionResult PostTeacherProfile(TeacherProfile teacherProfile) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.TeacherProfiles.Add(teacherProfile); db.SaveChanges(); return(CreatedAtRoute("DefaultApi", new { id = teacherProfile.PKTeachersId }, teacherProfile)); }
public HomeController(ILogger <HomeController> logger) { _logger = logger; //inheritence from PersonalDetails to DoctorProfile DoctorProfile Vicran = new DoctorProfile() { FirstName = "Vikrant Shrestha", Address = "Kathmnandu", Age = 21, Occupation = "Doctor", //DoctorProfile specific property HospitalClinic = "Grande Hospital", Qualification = "MD", Speciality = "NeuroSurgeon" }; detailList.Add(Vicran); //inheritence from PersonalDetails to TeacherProfile TeacherProfile Sinke = new TeacherProfile() { FirstName = "Aman Butthe", Address = "Darjeeling", Age = 20, Occupation = "Teacher", //TeacherProfile specific property Qualification = "B.Ed.", Institute = "JMC", AssociatedSubjects = "Mathematics" }; detailList.Add(Sinke); //inheritence from PersonalDetails to StudentProfile StudentProfile Sallu = new StudentProfile() { FirstName = "Salina Awal", Address = "Bhaktapur", Age = 23, Occupation = "Student", //StudentProfile specific property Faculty = "Architecture", College_School = "Pulchowk", Rollno = 15162 }; detailList.Add(Sallu); }
public async Task <IActionResult> Create([Bind("TeacherID,SchoolID,PostID,TName,FatherHusbandName,CNIC,IsFemale,IsProjectTeacher,ContractAward,ContractUrl,DateOfJoining,EcePreScore,EcePostScore,EstPreScore,EstPostScore,HTPreScore,HTPostScore,JoiningUrl")] TeacherProfile teacherProfile) { if (ModelState.IsValid) { if (teacherProfile.IsProjectTeacher == true) { teacherProfile.ContractAward = false; } _context.Add(teacherProfile); await _context.SaveChangesAsync(); //Save uploaded files var files = Request.Form.Files; if (!files.Any()) { return(RedirectToAction("Update", "IncdicatorTrackings", new { id = teacherProfile.SchoolID, secID = "926982" })); } string District = _context.Schools.Include(a => a.UC.Tehsil.District) .Where(a => a.SchoolID == teacherProfile.SchoolID) .Select(a => a.UC.Tehsil.District.DistrictName).FirstOrDefault(); //string var rootPath = Path.Combine( Directory.GetCurrentDirectory(), "wwwroot\\Documents\\IndicatorEvidences\\"); string sPath = Path.Combine(rootPath + District + "/" + "_TeachersContract" + "/", teacherProfile.SchoolID.ToString()); if (!System.IO.Directory.Exists(sPath)) { System.IO.Directory.CreateDirectory(sPath); } //short i = 1; string fileName = teacherProfile.TeacherID.ToString(); foreach (var file in files) { string FullPathWithFileName = Path.Combine(sPath, fileName + Path.GetExtension(file.FileName)); using (var stream = new FileStream(FullPathWithFileName, FileMode.Create)) { await file.CopyToAsync(stream); } } teacherProfile.ContractUrl = Path.Combine("/Documents/IndicatorEvidences/", District + "//" + "_TeachersContract" + "//" + teacherProfile.SchoolID + "//" + teacherProfile.TeacherID + ".pdf");//Server Path teacherProfile.ContractAward = true; teacherProfile.ContractDate = DateTime.Now; _context.Update(teacherProfile); await _context.SaveChangesAsync(); return(RedirectToAction("Update", "IncdicatorTrackings", new { id = teacherProfile.SchoolID, secID = "926982" })); } ViewData["SchoolID"] = new SelectList(_context.Schools, "SchoolID", "SName", teacherProfile.SchoolID); ViewData["PostID"] = new SelectList(_context.Set <TeacherPost>(), "PostID", "PostID", teacherProfile.PostID); return(View(teacherProfile)); }
public IHttpActionResult DeleteTeacherProfile(long id) { TeacherProfile teacherProfile = db.TeacherProfiles.Find(id); if (teacherProfile == null) { return(NotFound()); } db.TeacherProfiles.Remove(teacherProfile); db.SaveChanges(); return(Ok(teacherProfile)); }
public UserFilterResponse(int id, string name, string email, string avatarLink, bool isTeacher, TeacherProfile teacherProfile, bool isActive, Gender gender, DateTimeOffset birthYear) { Id = id; Name = name; Email = email; AvatarLink = avatarLink; Gender = gender; BirthYear = birthYear; IsTeacher = isTeacher; TeacherProfile = teacherProfile; IsActive = isActive; }
public ActionResult UserEnquires() { TeacherProfile teach = DbHelper.GetTeachers(Helper.UserId).FirstOrDefault(); if (teach == null) { List <UserEnquiry> lst = new List <UserEnquiry>(); return(View(lst)); } else { return(View(DbHelper.GetUserEnquiries(Convert.ToInt64(teach.PKTeachersId)))); } }
// GET: TeacherProfiles/Edit/5 public async Task <IActionResult> Edit() { string userName = User.Identity.Name; TeacherProfile profile = await GetCurrentuserAsync(); if (profile == null) { return(NotFound()); } ViewData["DegreeId"] = new SelectList(_context.Degrees, "Id", "Name", profile.DegreeId); ViewData["PostId"] = new SelectList(_context.Posts, "Id", "Name", profile.PostId); return(View(profile)); }
//constr for db internal User(string name, Credentials credentials, UserType type, List <Invitation> invitationList, TeacherProfile teacherProfile, UserProfile userProfile, bool isActive, List <Notification> notifiesList, NotificationsSettings notificationsSettings, int id = 0) { Id = id; Ensure.String.IsNotNullOrWhiteSpace(name); Credentials = Ensure.Any.IsNotNull(credentials); Type = type; TeacherProfile = Ensure.Any.IsNotNull(teacherProfile); UserProfile = Ensure.Any.IsNotNull(userProfile); IsActive = isActive; Invitations = Ensure.Any.IsNotNull(invitationList); Notifications = Ensure.Any.IsNotNull(notifiesList); NotificationsSettings = Ensure.Any.IsNotNull(notificationsSettings); }
public User(string name, Credentials credentials, bool isTeacher, UserType type, string avatarLink = "", int id = 0) { Id = id; Ensure.String.IsNotNullOrWhiteSpace(name); Credentials = Ensure.Any.IsNotNull(credentials); Type = type; TeacherProfile = new TeacherProfile(); UserProfile = new UserProfile(name, Credentials.Email, isTeacher, avatarLink); IsActive = true; Invitations = new List <Invitation>(); Notifies = new List <string>(); Notifications = new List <Notification>(); NotificationsSettings = new NotificationsSettings(); }
public TeacherProfile TeacherProfilePage(string userName) { try { LoginController.checkOnAccess(this.Request.Headers); } catch (Exception ex) { throw ex; }; TeacherProfile profile = new TeacherProfile(); profile.categories = new List <string>(); profile.classes = new List <SCourses>(); int teacherId = LoginController.GetUserID(userName, "teacher"); var db = new DBModel(); try { //Subjects list profile.categories = (from tcat in db.TeacherCategories where tcat.TeacherId == teacherId select tcat.Category).ToList(); //Classes list (CLassID, NAME, GRADE,) profile.classes = (from tcl in db.TeachersToClasses where tcl.TeacherId == teacherId join cg in db.ClassGroups on tcl.ClassId equals cg.Id orderby cg.Category, cg.Grade select new SCourses { CourseId = cg.Id, Category = cg.Category, Grade = cg.Grade }).ToList(); profile.Picture = (from u in db.Users where u.UserName == userName select u.Picture).First(); } catch (Exception ex) { throw ex; }; return(profile); }
public ActionResult EditClass(int id) { Category objCat = new Category(); Class cls = DbHelper.GetClass(id); TeacherProfile teacherProfile = DbHelper.GetTeacherProfile(id); objCat.Class = cls; objCat.TeacherProfile = teacherProfile; ViewBag.Subject = new SelectList(DbHelper.GetSubjects(), "PKSubjectId", "SubjectName", cls.FKSubjectId); List <City> citiesList = DbHelper.GetAllCities(); objCat.Cities = citiesList.Where(x => x.FKStateId == cls.City.FKStateId).ToList(); ViewBag.Cities = objCat.Cities; ViewBag.stateId = cls.City.FKStateId; ViewBag.States = new SelectList(DbHelper.GetStates(), "PKStateId", "StateName", cls.City.FKStateId); return(View(objCat)); }
public async Task <IActionResult> ChangePassword() { if (ModelState.IsValid) { TeacherProfile user = await GetCurrentuserAsync(); if (user != null) { ChangePasswordViewModel changeViewModel = new ChangePasswordViewModel() { Id = user.Id }; return(View(changeViewModel)); } } return(RedirectToAction(nameof(Index))); }
public static async Task InitializeRoleAsync(UserManager <TeacherProfile> userManager, RoleManager <IdentityRole> roleManager) { string adminEmail = "*****@*****.**"; string password = "******"; string[] roles = new string[] { "admin", "teacher", "user" }; foreach (var role in roles) { if (await roleManager.FindByNameAsync(role) == null) { await roleManager.CreateAsync(new IdentityRole(role)); } } if (await userManager.FindByNameAsync(adminEmail) == null) { TeacherProfile admin = new TeacherProfile { Email = adminEmail, UserName = "******", FirstName = "Admin", LastName = "Admin", MiddleName = "Admin", }; IdentityResult result = null; try { result = await userManager.CreateAsync(admin, password); } catch (Exception) { } finally { if (result != null && result.Succeeded) { await userManager.AddToRoleAsync(admin, "admin"); } } } }
// GET: TeacherProfiles/Create public IActionResult Create(int id) { TeacherProfile TeacherProfile = new TeacherProfile(); TeacherProfile.SchoolID = id; TeacherProfile.School = _context.Schools.Find(id); ViewBag.SchoolID = new SelectList(_context.Schools, "SchoolID", "SName"); //ViewBag.PostID = new SelectList(_context.TeacherPosts, "PostID", "PostName"); ViewBag.NullableBool = new SelectList(new[] { new { Id = "", Name = "" }, new { Id = "True", Name = "Yes" }, new { Id = "False", Name = "No" } }, "Id", "Name"); ViewData["PostID"] = new SelectList(_context.Set <TeacherPost>(), "PostID", "PostName"); return(View(TeacherProfile)); }
public async Task <ActionResult> EditUser(TeacherProfile model) { if (ModelState.IsValid) { try { await _teacherProfileService.Edit(model); TempData["success"] = "Update Successful."; return(RedirectToAction("Index")); } catch (Exception e) { TempData["error"] = "Update Unsuccessful, (" + e.ToString() + ")"; } } return(View(model)); }