public ActionResult RankOfProfessorInCollege(string id = null, string term = null) { SetViewBag(title: "رتبه بندی اساتید در سطح دانشکده", menuItem: "RankOfProfessorInCollege"); var collegeId = 0; var termId = 0; ViewBag.CollegeList = new SelectList(_collegeService.GetAll(), "Id", "Name"); ViewBag.TermList = new SelectList(_termService.GetAll().OrderByDescending(o => o.TermCode), "Id", "Name"); if (!string.IsNullOrEmpty(id)) { int.TryParse(id, out collegeId); } var user = (Models.User)Session["UserInfo"]; if (user != null && user.College != null) { collegeId = user.College.Id; } if (!string.IsNullOrEmpty(term) && int.TryParse(term, out termId) && termId > 0 && collegeId > 0) { ViewBag.CollegeName = _collegeService.Get(w => w.Id == collegeId).Name; //// Old Methode Start // var counter = 0; // var professors = _collegeService.Get(w => w.Id == collegeId).EducationalGroups.SelectMany(s => s.EducationalClasses).Where(w => w.Term.Id == termId) // .Select(s => s.Professor).OrderByDescending(o => o.ProfessorScores.Where(w => w.Term != null && w.Term.Id == termId).Sum(s => s.CurrentScore)).Distinct() // .Select(s => new Models.Professor // { // //Colleges = Mapper.Map<ICollection<Model.Models.College>, ICollection<Models.College>>(s.Colleges), // //EducationalGroups = Mapper.Map<ICollection<Model.Models.EducationalGroup>, ICollection<Models.EducationalGroup>>(s.EducationalGroups), // EducationalClasses = Mapper.Map<ICollection<Model.Models.EducationalClass>, ICollection<Models.EducationalClass>>(s.EducationalClasses), // ProfessorScores = Mapper.Map<ICollection<Model.Models.ProfessorScore>, ICollection<Models.ProfessorScore>>(s.ProfessorScores), // Name = s.Name, // Family = s.Family, // NationalCode = s.NationalCode, // ProfessorCode = s.ProfessorCode, // Gender = Convert.ToBoolean(s.Gender), // RankInUniversity = ++counter // }).ToList(); // return View(professors); //// Old Methode End var collegeList = new List <int>(); collegeList.Add(collegeId); var model = _reportService.GetProfessorReport(termId, collegeList: collegeList, allColleges: false).General.ToList(); foreach (var item in model) { item.RowNumber = model.IndexOf(item) + 1; } return(View(model)); } //else show error return(View()); }
public ActionResult RankOfEducationalGroupInCollege(string id = null, string term = null) { SetViewBag(title: "رتبه بندی گروه ها در سطح دانشکده ها", menuItem: "RankOfEducationalGroupInCollege"); var collegeId = 0; var termId = 0; ViewBag.CollegeList = new SelectList(_collegeService.GetAll(), "Id", "Name"); ViewBag.TermList = new SelectList(_termService.GetAll().OrderByDescending(o => o.TermCode), "Id", "Name"); if (!string.IsNullOrEmpty(id)) { int.TryParse(id, out collegeId); } var user = (Models.User)Session["UserInfo"]; if (user != null && user.College != null) { collegeId = user.College.Id; } if (!string.IsNullOrEmpty(term) && int.TryParse(term, out termId) && termId > 0 && collegeId > 0) { ViewBag.CollegeName = _collegeService.Get(w => w.Id == collegeId).Name; //// Old Methode Start //var counter = 0; //var groups = _educationalGroupService.GetMany(g=> g.College.Id == collegeId).Select(s=> new Models.EducationalGroup { // Id = s.Id, // EducationalGroupCode = s.EducationalGroupCode, // Name = s.Name, // EducationalGroupScores = Mapper.Map<List<Models.EducationalGroupScore>>(s.EducationalGroupScores), // EducationalClasses = Mapper.Map<List<Models.EducationalClass>>(s.EducationalClasses), // GroupManger = Mapper.Map<Models.Professor>(s.GroupManger), // College = Mapper.Map<Models.College>(s.College), // RankInUniversity = ++counter //}) //.ToList(); //return View(groups); //// Old Methode End var currentTerm = GetCurrentTerm(); var collegeList = new List <int>(); collegeList.Add(collegeId); var model = _reportService.GetGroupReport(termId, collegeList: collegeList, allColleges: false).General.ToList(); foreach (var item in model) { item.RowNumber = model.IndexOf(item) + 1; } return(View(model)); } return(View()); }
public ActionResult AddOrUpdateUser(string id, string username, string college, string group, string firstName, string lastName, string password, string isAdministrator, string isPowerUser, string serviceUsername) { var userId = Convert.ToInt32(id); var actionDone = false; if (userId > 0) { var user = _userService.Get(g => g.ID == userId); if (!Convert.ToBoolean(isAdministrator) && !Convert.ToBoolean(isPowerUser)) { if (!string.IsNullOrEmpty(college)) { var collegeId = Convert.ToInt32(college); user.College = _collegeService.Get(g => g.Id == collegeId); } if (!string.IsNullOrEmpty(group)) { var groupCode = Convert.ToInt32(group); user.EducationalGroupCode = groupCode;//.EducationalGroup = _educationalGroupService.Get(g => g.Id == groupId); } } else { user.College = null; user.EducationalGroupCode = null; } user.Username = username; user.FirstName = firstName; user.LastName = lastName; if (!string.IsNullOrEmpty(password)) { user.Password = password.GetMd5Hash(); } user.IsAdministrator = Convert.ToBoolean(isAdministrator); user.IsPowerUser = Convert.ToBoolean(isPowerUser); _userService.Update(user); actionDone = true; } else { var existUser = _userService.Get(g => g.Username == username); if (username.ToLower() != "sync" && existUser == null) { var user = new User(); user.Username = username; if (!string.IsNullOrEmpty(college)) { var collegeId = Convert.ToInt32(college); user.College = _collegeService.Get(g => g.Id == collegeId); } if (!string.IsNullOrEmpty(group)) { var groupCode = Convert.ToInt32(group); user.EducationalGroupCode = groupCode;//_educationalGroupService.Get(g => g.Id == groupId); } user.FirstName = firstName; user.LastName = lastName; if (!string.IsNullOrEmpty(password)) { user.Password = password.GetMd5Hash(); } user.IsAdministrator = Convert.ToBoolean(isAdministrator); user.IsPowerUser = Convert.ToBoolean(isPowerUser); _userService.Add(user); actionDone = true; } } if (actionDone) { var map = _serviceUsersMappingService.Get(g => g.Username == username); if (map == null) { _serviceUsersMappingService.Add(new ServiceUsersMapping { Username = username, ServiceUsername = serviceUsername }); } else { map.ServiceUsername = serviceUsername; _serviceUsersMappingService.Update(map); } } return(null); }
public async Task <ActionResult <CollegeDto> > Get() { var shippingCompanies = _mapper.Map <IList <CollegeDto> >(await _CollegeService.Get()); return(Response(shippingCompanies)); }