Ejemplo n.º 1
0
 public static LeaveRequest CommentLeaveRequest(HrmContext ctx, LeaveRequestComment comment)
 {
     var target = ctx.DbContext.LeaveRequests.Find(comment.RequestId);
     if (target == null) throw new GraphQL.ExecutionError("request not exists");
     comment.Type = CommentType.Comment;
     ctx.DbContext.Add(comment);
     return target;
 }
Ejemplo n.º 2
0
 public static LeaveRequest ApproveLeaveRequest(HrmContext ctx, LeaveRequestComment comment)
 {
     var target = ctx.DbContext.LeaveRequests.Find(comment.RequestId);
     var canApprove = target.CanApproveBy(ctx.UserContext.Identity.Name);
     if (!canApprove.able) throw new GraphQL.ExecutionError(canApprove.reason);
     comment.Type = CommentType.Approve;
     target.State = LeaveRequestState.Processing;
     ctx.DbContext.Add(comment);
     return target;
 }