public async Task <ReturnData <bool> > CreateAsync(AddSalaryDto model)
        {
            var result  = new ReturnData <bool>();
            var salarys = await _context.Salarys.FirstOrDefaultAsync(i => i.StaffInfoId == model.StaffInfoId && i.CreateTime.ToString("yy/MM") == DateTime.Now.ToString("yy/MM"));

            if (salarys != null)
            {
                result.Message = "当月此员工已经录入工资,录入失败";
                result.Result  = false;
                return(result);
            }
            _context.Salarys.Add(new Model.Model.Salary
            {
                CreateTime            = DateTime.Now,
                StaffInfoId           = model.StaffInfoId,
                BasicSalary           = model.BasicSalary,
                Deduction             = model.Deduction,
                LastUpTime            = DateTime.Now,
                MealSubsidy           = model.MealSubsidy,
                OtherSubsidies        = model.OtherSubsidies,
                Reward                = model.Reward,
                TransportationSubsidy = model.TransportationSubsidy,
            });
            result.Result = await _context.SaveChangesAsync() > 0;

            return(result);
        }
Beispiel #2
0
        public async Task <IActionResult> Create(AddSalaryDto model)
        {
            var result = await _service.CreateAsync(model);

            return(Ok(result));
        }