示例#1
0
        public void SubmitLeave(List <long> list, ETecLeave tecLeave)
        {
            try
            {
                tecLeave.ApplyDateTime = DateTime.Now;

                _dbContext.Database.BeginTransaction();
                var sql = sql_UpdateTecCourseLeaveBatch(list);
                _dbContext.Database.ExecuteSqlRaw(sql);
                var dbleave = _dbContext.DBTecLeave.Where(a => a.TecCode == tecLeave.TecCode &&
                                                          a.LeaveDate.ToString("yyyy-MM-dd") == tecLeave.LeaveDate.ToString("yyyy-MM-dd")).FirstOrDefault();
                if (dbleave == null)
                {
                    _dbContext.DBTecLeave.Add(tecLeave);
                }
                else
                {
                    dbleave.LeaveType = tecLeave.LeaveType;
                }
                _dbContext.SaveChanges();

                _dbContext.Database.CommitTransaction();
            }
            catch (Exception ex)
            {
                _dbContext.Database.RollbackTransaction();
                throw ex;
            }
        }
示例#2
0
        public IActionResult OnPostSubmitTecLeave(List <long> list, ETecLeave tecLeave)
        {
            ResultNormal result = new ResultNormal();

            try
            {
                _TecSrv.SubmitLeave(list, tecLeave);
            }
            catch (Exception ex)
            {
                result.ErrorMsg = "请假失败,请联系管理员";
                NLogHelper.ErrorTxt($"后台新增请假[OnPostSubmitTecLeave]:{ex.Message}");
            }

            return(new JsonResult(result));
        }