的
This commit is contained in:
parent
9e3d1254b4
commit
c9db953153
@ -139,22 +139,35 @@ namespace VOL.Business.Services.School
|
|||||||
school_Entity.CreateDate = DateTime.Now;
|
school_Entity.CreateDate = DateTime.Now;
|
||||||
school_Entity.Creator = UserContext.Current.UserId;
|
school_Entity.Creator = UserContext.Current.UserId;
|
||||||
|
|
||||||
var natureList = await _natureAssocGradeRepository.FindAsync(x => x.NatureId == paramDto.SchoolNatureId);
|
|
||||||
if (natureList == null || natureList.Count == 0)
|
|
||||||
throw new Exception($"未找到学校性质:{paramDto.SchoolNatureId}");
|
|
||||||
|
|
||||||
var user = await _userRepository.FindAsyncFirst(x => x.UserName == paramDto.UserName && x.Role_Id == 2);
|
|
||||||
if (user != null)
|
|
||||||
throw new Exception($"用户名为{paramDto.UserName}的学校已存在");
|
|
||||||
|
|
||||||
var gradeEntityList = new List<S_SchoolAssocGrade>();
|
var gradeEntityList = new List<S_SchoolAssocGrade>();
|
||||||
|
|
||||||
foreach (var nature in natureList)
|
if (paramDto.SchoolType == SchoolType.School)
|
||||||
{
|
{
|
||||||
|
var natureList = await _natureAssocGradeRepository.FindAsync(x => x.NatureId == paramDto.SchoolNatureId);
|
||||||
|
if (natureList == null || natureList.Count == 0)
|
||||||
|
throw new Exception($"未找到学校性质:{paramDto.SchoolNatureId}");
|
||||||
|
|
||||||
|
var user = await _userRepository.FindAsyncFirst(x => x.UserName == paramDto.UserName && x.Role_Id == 2);
|
||||||
|
if (user != null)
|
||||||
|
throw new Exception($"用户名为{paramDto.UserName}的学校已存在");
|
||||||
|
|
||||||
|
foreach (var nature in natureList)
|
||||||
|
{
|
||||||
|
gradeEntityList.Add(new S_SchoolAssocGrade()
|
||||||
|
{
|
||||||
|
SchoolCode = nextSchoolCode,
|
||||||
|
GradeId = nature.GradeId
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var grade = await _gradeRepository.FindAsIQueryable(x => x.GradeName == "运动馆").FirstOrDefaultAsync();
|
||||||
gradeEntityList.Add(new S_SchoolAssocGrade()
|
gradeEntityList.Add(new S_SchoolAssocGrade()
|
||||||
{
|
{
|
||||||
SchoolCode = nextSchoolCode,
|
SchoolCode = nextSchoolCode,
|
||||||
GradeId = nature.GradeId
|
GradeId = grade?.Id ?? 0
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -62,7 +62,7 @@ namespace VOL.Model.School.Request
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
///学校性质Id
|
///学校性质Id
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int SchoolNatureId { get; set; }
|
public int? SchoolNatureId { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///学校编号
|
///学校编号
|
||||||
|
Loading…
x
Reference in New Issue
Block a user