예제 #1
0
        /// <summary>
        /// 家长给学生测温记录
        /// </summary>
        /// <param name="parentId"></param>
        /// <param name="studentId"></param>
        /// <param name="specDay"></param>
        /// <param name="temperature"></param>
        /// <param name="photoUrl"></param>
        /// <returns></returns>
        public bool AddByParent(Guid parentId, Guid studentId, DateTime specDay, decimal temperature, string photoUrl)
        {
            try
            {
                var q = Db.StudentParent.Where(x => x.ParentId == parentId && x.StudentId == studentId);
                if (!q.Any())
                {
                    ErrorMessage = "家长或者学生信息不存在!";
                    ErrorNumber  = (int)EnumErrors.信息不存在;
                    return(false);
                }

                var sp = q.SingleOrDefault();

                var bbt = new StudentBbtRecord();
                bbt.Checkintime        = DateTime.Now;
                bbt.ParentId           = parentId;
                bbt.PhotoUrl           = photoUrl;
                bbt.SpecDay            = specDay.Date;
                bbt.Status             = (byte)EnumDataStatus.Normal;
                bbt.StudentBbtRecordId = Guid.NewGuid();
                bbt.StudentId          = studentId;
                bbt.Temperature        = temperature;
                bbt.Type = (byte)EnumBbtType.家测;
                Db.StudentBbtRecord.Add(bbt);

                //增加信息提示
                var tips = new Tips();
                tips.ActionTime  = DateTime.Now;
                tips.Checkintime = DateTime.Now;
                tips.Content     = $"家中测温为{temperature:F1}摄氏度";
                if (temperature > (decimal)37.3)
                {
                    tips.FontColor = "red";
                }
                else
                {
                    tips.FontColor = "green";
                }

                tips.Status    = (byte)EnumDataStatus.Normal;
                tips.StudentId = studentId;
                tips.TipsId    = Guid.NewGuid();
                tips.Type      = (byte)EnumTipsType.测温;
                Db.Tips.Add(tips);

                Db.SaveChanges();

                return(true);
            }
            catch (Exception ex)
            {
                SetError(ex);
                return(false);
            }
        }
예제 #2
0
        /// <summary>
        /// 记录学校测学生体温
        /// </summary>
        /// <param name="teacherId"></param>
        /// <param name="studentId"></param>
        /// <param name="specDay"></param>
        /// <param name="type"></param>
        /// <param name="temperature"></param>
        /// <param name="photoUrl"></param>
        /// <returns></returns>
        public bool AddByTeacher(Guid teacherId, Guid studentId, DateTime specDay, EnumBbtType type, decimal temperature, string photoUrl)
        {
            try
            {
                var q = Db.Student.Where(x => x.StudentId == studentId && x.Team.TeamTeacher.Any(y => y.TeacherId == teacherId));
                if (!q.Any())
                {
                    ErrorMessage = "家长或者学生信息不存在!";
                    ErrorNumber  = (int)EnumErrors.信息不存在;
                    return(false);
                }

                var student = q.SingleOrDefault();

                var bbt = new StudentBbtRecord();
                bbt.Checkintime        = DateTime.Now;
                bbt.TeacherId          = teacherId;
                bbt.PhotoUrl           = photoUrl;
                bbt.SpecDay            = specDay;
                bbt.Status             = (byte)EnumDataStatus.Normal;
                bbt.StudentBbtRecordId = Guid.NewGuid();
                bbt.StudentId          = studentId;
                bbt.Temperature        = temperature;
                bbt.Type = (byte)type;
                Db.StudentBbtRecord.Add(bbt);

                //增加信息提示
                var tips = new Tips();
                tips.ActionTime  = DateTime.Now;
                tips.Checkintime = DateTime.Now;
                tips.Content     = $"学校测温为{temperature:F1}摄氏度";
                if (temperature > (decimal)37.3)
                {
                    tips.FontColor = "red";
                }
                else
                {
                    tips.FontColor = "green";
                }

                tips.Status    = (byte)EnumDataStatus.Normal;
                tips.StudentId = studentId;
                tips.TipsId    = Guid.NewGuid();
                tips.Type      = (byte)EnumTipsType.测温;
                Db.Tips.Add(tips);

                Db.SaveChanges();

                return(true);
            }
            catch (Exception ex)
            {
                var sb = new StringBuilder();
                sb.AppendLine(ex.Message);
                if (ex is DbEntityValidationException)
                {
                    sb.AppendLine("验证异常:");
                    foreach (var item in ((DbEntityValidationException)ex).EntityValidationErrors)
                    {
                        foreach (var error in item.ValidationErrors)
                        {
                            sb.AppendLine(error.ErrorMessage);
                        }
                    }
                }
                ErrorMessage = sb.ToString();
                return(false);
            }
        }