Exemplo n.º 1
0
        public async Task <object> AddApplication([FromBody] AddApplicationDto addApplicationDto)
        {
            var    context = HttpContext;
            string account = await _jwtUtil.GetMessageByToken(context);

            addApplicationDto.CompId      = _commonAppService.GetUserCompId(account);
            addApplicationDto.DeparmentId = _commonAppService.GetUserDepId(account);
            return(_approvalAppService.AddApplication(addApplicationDto));
        }
Exemplo n.º 2
0
        public object AddApplication(AddApplicationDto addApplicationDto)
        {
            var result      = new object();
            var application = _ctx.Apply.SingleOrDefault(a => a.WorkerId == addApplicationDto.WorkerId &&
                                                         a.StartTime <= addApplicationDto.StartTime && a.EndTime >= addApplicationDto.EndTime);
            //状态
            int state = addApplicationDto.IsSubmit ? ApprovalHelper.DEFAULT_APPROVAL_STATE : 0;

            if (application != null)
            {
                result = new
                {
                    isSuccess = false,
                    message   = "您已有该时间段的假期!"
                }
            }
            ;
            else
            {
                Apply newApply = new Apply()
                {
                    WorkerId    = addApplicationDto.WorkerId,
                    DeparmentId = addApplicationDto.DeparmentId,
                    CompanyId   = addApplicationDto.CompId,
                    Type1       = addApplicationDto.Type1,
                    Type2       = addApplicationDto.Type2,
                    Account     = addApplicationDto.Account,
                    State       = ApprovalHelper.DEFAULT_APPROVAL_STATE,
                    IsSubmit    = addApplicationDto.IsSubmit,
                    StartTime   = addApplicationDto.StartTime,
                    EndTime     = addApplicationDto.EndTime,
                    CreateTime  = DateTime.Now.ToFileTime(),
                    IsRevoke    = false,
                };
                _ctx.Apply.Add(newApply);
                _ctx.SaveChanges();
                result = new
                {
                    isSuccess = true,
                    message   = "申请已保存!"
                };
                //添加完成后添加通知
                if (newApply.State == 1)
                {
                    AddInform(newApply.Id, newApply.WorkerId, "Leave");
                }
            }
            return(result);
        }
Exemplo n.º 3
0
        public async Task <object> AddApplication([FromBody] AddApplicationDto addApplicationDto)
        {
            var    context = HttpContext;
            string account = await _jwtUtil.GetMessageByToken(context);

            addApplicationDto.CompId      = _commonAppService.GetUserCompId(account);
            addApplicationDto.DeparmentId = _commonAppService.GetUserDepId(account);
            Result result = _approvalAppService.AddApplication(addApplicationDto);

            if (result.Id != 0)
            {
                await _signalrHubs.Send(result.Id.ToString(), "您有新的消息");
            }
            return(result);
        }
 public object AddApplication(AddApplicationDto addApplicationDto)
 {
     return(_approvalManager.AddApplication(addApplicationDto));
 }