Click or drag to resize

ServiceRouterUpdateUserTimeApproval Method

Returns a UpdateUserTimeApprovalOut response with a result model List<UpdateUserTimeApprovalModel>

Namespace: AppOne.Services.V2
Assembly: AppOne.Web.Service (in AppOne.Web.Service.dll) Version: 1.0.141
Syntax
public UpdateUserTimeApprovalOut UpdateUserTimeApproval(
	UpdateUserTimeApprovalIn input
)

Parameters

input  UpdateUserTimeApprovalIn
A new UpdateUserTimeApprovalIn object

Return Value

UpdateUserTimeApprovalOut
A UpdateUserTimeApprovalOut object
Remarks
Use this method to get a results list of UpdateUserTimeApprovalModel which contains the result for updating time card approvals.

ValidationType Options

NameDescription
BASIC This action will do minimal validation and is recommended if you do not want do full validation checking. The validation for this mode includes:
- Validation of the EmpIdentifier
- Validation that all ApprovedBy EmpIdentifer values are valid
Note  Note
Request Limits
The API will only allow a maximum of 100 approval updates to be sent in a single request. If you attempt to send more than 100 it will fail and you will receive a message indicating this If you need to approve greater than 100 items it is advised to send them in batches of 100 or less.

Business Rules:
Approving in and out punches is the core of the time-web system. The WSUserTimeApproval class encapsulate the needed methods/operations to interact with a users time entry approval process.

Setup:
Employee > Dashboard
Manager > Time Cards > Time Card Approvals

Example
JSON Request
{
    "AuthToken":"...",
    "ValidationType" : "BASIC",
    "Payload":[{
        "EmpIdentifier":"5555",
        "TimePreSliceID":136,
        "EmpApproved":true
    },
    {        
        "EmpIdentifier":"5555",
        "TimePreSliceID":137,
        "EmpApproved":true,
        "MgrApproved1":true,
        "MgrApproved1By":"1234",
        "MgrApproved2":true,
        "MgrApproved2By":"1234",
        "AdminApproved":false,
        "AdminApprovedBy":"1234"        
    },
    {
        "EmpIdentifier":"777",
        "TimePreSliceID":128,
        "EmpApproved":false    
    },
    {
        "EmpIdentifier":"5555",
        "TimePreSliceID":11,
        "EmpApproved":false    
    }]
}
JSON Response
{
   "Report":    {
      "APIVersion": "2.0",
      "ProcessTime": "0.0396155",
      "RequestTime": "/Date(1479243951478-0700)/",
      "ResponseTime": "/Date(1479243951518-0700)/",
      "Results": 4
   },
   "Results":    [
      {
         "ID": 136,
         "Messages": ["PASS: EmpApproved updated to True"],
         "Status": 1
      },
      {
         "ID": 137,
         "Messages":          [
            "PASS: AdminApproved updated to False",
            "PASS: MgrApproved1 updated to True",
            "PASS: MgrApproved2 updated to True",
            "PASS: EmpApproved updated to True"
         ],
         "Status": 1
      },
            {
         "ID": 0,
         "Messages": ["FAIL: EmpIdentifier '777' not found"],
         "Status": 0
      },
            {
         "ID": 11,
         "Messages": ["FAIL: TimeSlicePreID '11' not found for EmpIdentifier '5555'"],
         "Status": 0
      }
   ]
}
SOAP: C# WCF Sample
public class TimeCardApprovalTest : BaseServiceTest
{
    [TestMethod]
    [TestCategory("SOAP_V2")]
    public void V2_UpdateUserTimeApproval_SOAPTest()
    {

        try
        {
            var actionTestLogic = new Action<SoapServiceV2.ServiceRouterClient>((client) =>
            {
                AppOne.Core.Security.Token token = new AppOne.Core.Security.Token().GetToken(WSCustomerAlias, WSUserName, WSUserPass, "en-us", AppOne.Core.Security.Token.SourceTypes.WebService);
                string empID = System.Configuration.ConfigurationManager.AppSettings["Test.UserInfo.EmpIdentifier"];
                bool isUpdate = false;
                int userID = new UserInfo().GetUserByEmployeeIdentifier(token, empID).UserID;
                TimeSlicePre timeSlicePre = new TimeSlicePre()
                {
                    UserID = userID,
                    PayTypeID = PayType.PayTypes.Work.GetHashCode(),
                    TransactionDateTime = DateTime.Now.Date,
                    TransactionUTCDateTime = DateTime.UtcNow.Date,
                    ClosedType = TimeSlicePre.ClosedTypes.Open,
                    TransactionType = TimeSlicePre.TransactionTypes.ClockIn,
                    TransactionSource = TimeSlicePre.TransactionSources.WebServices
                };

                int timeSlicePreID = timeSlicePre.Add(token, 0, true, true, null).FirstOrDefault().TimeSlicePreID;

                SoapServiceV2.UpdateUserTimeApprovalRequest request = new SoapServiceV2.UpdateUserTimeApprovalRequest();
                SoapServiceV2.UpdateUserTimeApprovalRequest request1 = new SoapServiceV2.UpdateUserTimeApprovalRequest();

                //Approve TimeCard
                List<UpdateUserTimeApprovalModel> payLoad = new List<UpdateUserTimeApprovalModel>();
                payLoad.Add(new UpdateUserTimeApprovalModel
                {
                    AdminApproved = true,
                    AdminApprovedBy = empID,
                    MgrApproved1 = true,
                    MgrApproved1By = empID,
                    MgrApproved2 = true,
                    MgrApproved2By = empID,
                    EmpApproved = true,
                    EmpIdentifier = empID,
                    TimePreSliceID = timeSlicePreID
                });
                request.input = new SoapServiceV2.UpdateUserTimeApprovalIn()
                {
                    AuthToken = AuthToken,
                    Payload = payLoad
                };
                timeSlicePre = new TimeSlicePre().GetTimeSliceInfoFromPreIds(token, userID, new List<int>() { timeSlicePreID }).FirstOrDefault();
                if (timeSlicePre.AdminApproved && timeSlicePre.MgrApproved && timeSlicePre.Mgr2Approved && timeSlicePre.EmpApproved)
                {
                    isUpdate = true;
                }

                //Unapproved TimeCard
                payLoad = new List<UpdateUserTimeApprovalModel>();
                payLoad.Add(new UpdateUserTimeApprovalModel
                {
                    AdminApproved = false,
                    AdminApprovedBy = empID,
                    MgrApproved1 = false,
                    MgrApproved1By = empID,
                    MgrApproved2 = false,
                    MgrApproved2By = empID,
                    EmpApproved = false,
                    EmpIdentifier = empID,
                    TimePreSliceID = timeSlicePreID
                });

                request.input = new SoapServiceV2.UpdateUserTimeApprovalIn()
                {
                    AuthToken = AuthToken,
                    Payload = payLoad
                };
                timeSlicePre = new TimeSlicePre().GetTimeSliceInfoFromPreIds(token, userID, new List<int>() { timeSlicePreID }).FirstOrDefault();
                if (!timeSlicePre.AdminApproved && !timeSlicePre.MgrApproved && !timeSlicePre.Mgr2Approved && !timeSlicePre.EmpApproved)
                {
                    isUpdate = true;
                }
                timeSlicePre.DeleteAndProcess(token, true);
                SoapServiceV2.UpdateUserTimeApprovalResponse response = client.UpdateUserTimeApproval(request);
                Assert.IsTrue(isUpdate && (response.UpdateUserTimeApprovalResult.Results != null ? response.UpdateUserTimeApprovalResult.Results.Count : 0) > 0);
            });

            RunServiceClient(actionTestLogic);
        }
        catch (FaultException<SoapServiceV2.ServiceException> fe)
        {
            Assert.Fail(fe.Detail.Message);
        }
    }
See Also