public async Task <ActionResult <AcStaff> > GetOperator() { int id = int.Parse(_httpContext.HttpContext.User.FindFirst("operator_id").Value); var data = (await _IAcUserinfoService.Search(t => t.Id == id)).FirstOrDefault(); var data2 = (await _IAcStaffService.Search(t => t.Id == data.StaffId)).FirstOrDefault(); return(Ok(data2)); }
public async Task <ActionResult <IEnumerable <AcStaff> > > GetAllStaffInfo() { var data = (await _IAcStaffService.Search(t => true)).ToList(); var data2 = _mapper.Map <List <AcStaffDtos> >(data); foreach (var item in data2) { if (item.Sex == 1) { item.SexName = "男"; } else { item.SexName = "女"; } if (item.Status == 1) { item.StatusStr = "在职"; } else if (item.Status == 0) { item.StatusStr = "离职"; } } return(Ok(data2)); }
public async Task <ActionResult <InfoResult <AcSalaryDtos> > > AddSalary(AcSalaryDtos acSalaryDtos) { var NewSalary = (await _IAcStaffService.Search(u => u.Id == acSalaryDtos.StaffId)).FirstOrDefault(); var salaryList = await _IAcSalaryService.Search(t => true); int max = 0; foreach (var item in salaryList) { if (item.Id > max) { max = item.Id; } } acSalaryDtos.Id = max + 1; acSalaryDtos.Address = NewSalary.Address; acSalaryDtos.DepartmentName = NewSalary.Department.Name; acSalaryDtos.Name = NewSalary.Name; acSalaryDtos.sex = NewSalary.Sex; acSalaryDtos.StaffId = NewSalary.Id; acSalaryDtos.tel = NewSalary.Tel; acSalaryDtos.Createdate = DateTime.Now.ToString(); acSalaryDtos.Createdate = acSalaryDtos.Createdate.Substring(0, 10); acSalaryDtos.Sum = acSalaryDtos.Base + acSalaryDtos.Lunch + acSalaryDtos.Live + acSalaryDtos.Hardwork + acSalaryDtos.Extra + acSalaryDtos.Forfeit + acSalaryDtos.Tax; InfoResult <AcSalaryDtos> messageModel = new InfoResult <AcSalaryDtos>(); var data = await _IAcSalaryService.Add(_mapper.Map <AcSalary>(acSalaryDtos)); if (data > 0) { messageModel.Msg = "添加成功!"; messageModel.Code = 200; messageModel.Success = true; } else { messageModel.Msg = "添加失败!"; messageModel.Code = 400; messageModel.Success = false; } return(Ok(messageModel)); }