username@email.com
2022-10-18 378725af30f2ccf5007f80c553865be2b39f727a
zhengcaioa/Services/HrJibengongziService.cs
@@ -198,5 +198,93 @@
            var list = _mapper.Map<List<HrJibengongziDTO>>(listPosition);
            return list;
        }
        /// <summary>
        /// 获取所有有效角色
        /// </summary>
        /// <returns></returns>
        public List<HrShebaoDTO> GetListShebao()
        {
            var listRole = (from a in _context.HrShebaos
                            where a.RecStatus == "A"
                            select new HrShebaoDTO
                            {
                                Id = a.Id,
                                Shebaodanwei = a.Shebaodanwei??0,
                                Shebaogeren = a.Shebaogeren?? 0,
                                ShebaodanweiName = a.Shebaodanwei.HasValue ? a.Shebaodanwei.Value.ToString("F2") : "",
                                ShebaogerenName = a.Shebaogeren.HasValue ? a.Shebaogeren.Value.ToString("F2") : "",
                                Creater = a.Creater,
                                Createtime = a.Createtime,
                                RecStatus = a.RecStatus,
                                Modifier = a.Modifier,
                                Modifytime = a.Modifytime,
                            }
                ).OrderByDescending(x => x.Createtime).ToList();
            return listRole;
        }
        public ResultEntity saveShebao(HrShebaoDTO dto)
        {
            ResultEntity resultEntity = new ResultEntity();
            try
            {
                var entity = _mapper.Map<HrShebao>(dto);
                if (String.IsNullOrEmpty(entity.Id))
                {
                    entity.Id = Guid.NewGuid().ToString();
                    dto.Id = entity.Id;
                    _context.HrShebaos.Add(entity);
                }
                else
                {
                    var updateproject = _context.HrShebaos.Find(entity.Id);
                    updateproject.Shebaodanwei = entity.Shebaodanwei;
                    updateproject.Shebaogeren = entity.Shebaogeren;
                    updateproject.RecStatus = entity.RecStatus;
                    updateproject.Modifier = entity.Modifier;
                    updateproject.Modifytime = entity.Modifytime;
                }
                _context.SaveChanges();
                resultEntity.ReturnID = entity.Id;
                resultEntity.Result = true;
            }
            catch (Exception ex)
            {
                resultEntity.Result = false;
                resultEntity.Message = "保存失败,请联系管理员";
            }
            return resultEntity;
        }
    }
}