public ActionResult Input(Models.QualitySelf.Input vm) { return(Code.MvcHelper.Post(null, Url.Action("Input", new { yearId = vm.YearId, }))); }
public ActionResult Input() { if (Code.Common.UserType != Code.EnumHelper.SysUserType.Student) { return(Content(Code.Common.Redirect(Url.Action("Index", "SysIndex", new { area = "Sys" }), "当前身份类别无法访问该功能!"))); } using (var db = new XkSystem.Models.DbContext()) { var vm = new Models.QualitySelf.Input(); //获取学期 vm.YearList = Basis.Controllers.YearController.SelectList(Code.EnumHelper.YearType.Term); //获取当前激活学段 var section = (from p in db.Table <Basis.Entity.tbYear>() .Include(d => d.tbYearParent) where p.IsDeleted == false && p.IsDefault == true && (vm.YearId == 0 ? true : p.tbYearParent.Id == vm.YearId) select p).FirstOrDefault(); if (vm.YearList.Count > 0 && vm.YearId == 0 && section != null && section.YearType == Code.EnumHelper.YearType.Section) { vm.YearId = vm.YearList.Where(d => (section != null ? d.Value == section.tbYearParent.Id.ToString() : true)).FirstOrDefault().Value.ConvertToInt(); } vm.YearDefault = section != null ? true : false; //获取学生信息 var student = (from p in db.Table <Student.Entity.tbStudent>() where p.IsDeleted == false && p.tbSysUser.IsDeleted == false && p.tbSysUser.Id == Code.Common.UserId select p).FirstOrDefault(); if (student != null) { //自评 var self = (from p in db.Table <Quality.Entity.tbQualitySelf>() where p.IsDeleted == false && p.tbYear.IsDeleted == false && p.tbStudent.Id == student.Id && p.tbYear.Id == vm.YearId select new Dto.QualitySelf.Input { Id = p.Id, Content = p.Content, Type = 1, }).FirstOrDefault(); if (self != null) { vm.QualitySelfList.Add(self); } //学期期待 var plan = (from p in db.Table <Quality.Entity.tbQualityPlan>() where p.IsDeleted == false && p.tbYear.IsDeleted == false && p.tbStudent.Id == student.Id && p.tbYear.Id == vm.YearId select new Dto.QualitySelf.Input { Id = p.Id, Content = p.Content, Type = 2, }).FirstOrDefault(); if (plan != null) { vm.QualitySelfList.Add(plan); } //学期总结 var summary = (from p in db.Table <Quality.Entity.tbQualitySummary>() where p.IsDeleted == false && p.tbYear.IsDeleted == false && p.tbStudent.Id == student.Id && p.tbYear.Id == vm.YearId select new Dto.QualitySelf.Input { Id = p.Id, Content = p.Content, Type = 3, }).FirstOrDefault(); if (summary != null) { vm.QualitySelfList.Add(summary); } } return(View(vm)); } }