Click or drag to resize

ServiceRouterAddUserLaborLevel Method

Adds a AddUserLaborLevelOut response with a result model List<AddUserLaborLevelModel>

Namespace: AppOne.Services.V2
Assembly: AppOne.Web.Service (in AppOne.Web.Service.dll) Version: 1.0.141
Syntax
public AddUserLaborLevelOut AddUserLaborLevel(
	AddUserLaborLevelIn input
)

Parameters

input  AddUserLaborLevelIn
A new AddUserLaborLevelIn object

Return Value

AddUserLaborLevelOut
A AddUserLaborLevelOut object
Remarks
Use this method to add a payload of AddUserLaborLevelModel which contains the default and assigned labor-level-details for a user.

Note  Note
Business Rules:
Labor levels are used to create a structure for labor distribution, job costing and reporting. Labor-level-details track where employees spend their time. Employees are only able punch against specific labor-level-details to which they are assigned. Employees can be assigned to home or default labor-level-details by which they can be automatically assigned when accessing specific interfaces. Labor-levels (GetLaborLevelModel) are merely group containers for labor-level-details (GetLaborLevelDetailModel); basically a GetLaborLevelDetailModel is a child element of GetLaborLevelModel.

Setup:
Manager > Employees > Labor Levels
Configuration > Imports > New Employee Defaults
Configuration > Labor Levels > Define (Labor Levels GetLaborLevelModel)
Configuration > Labor Levels > Setup (Labor Levels Details GetLaborLevelDetailModel)
Caution note  Caution
When "Implied Labor Level Hierarchy" is enabled it will change the way in which labor levels are displayed for a given users. See Configuration > Labor Levels Hierarchy (which is enabled from the General Configuration interface).
Caution note  Caution
This method will except a maximum of 50 EmpIdentifier items per request. Any more than 50 and an exception will be return. This check is to prevent queuing issues from happening and locking up system resources.
Example
JSON Request
{
    "AuthToken":"...",
      "Payload":[{
        "EmpIdentifier":"1234",
        "AssignedLaborLevelDetails":[{
            "ChargeRate":55.55,
            "EffDate":"\/Date(1475305200000-0700)\/",
            "ID":2,
            "PayRate":66.66
        }],
        "HomeLaborLevelDetails":{
            "LL01EffDate":"\/Date(1475305200000-0700)\/",
            "LL01ID":6,
            "LL02EffDate":"\/Date(1475305200000-0700)\/",
            "LL02ID":7
        }
    },
    {
        "EmpIdentifier":"9999",
        "AssignedLaborLevelDetails":[],
        "HomeLaborLevelDetails":{
            "LL01EffDate":"\/Date(1475305200000-0700)\/",
            "LL01ID":6
        }
    }
    ]
}
JSON Response
{
   "Report":    {
      "APIVersion": "2.0",
      "ProcessTime": "0.2572916",
      "RequestTime": "/Date(1476299534346-0700)/",
      "ResponseTime": "/Date(1476299534604-0700)/",
      "Results": 2
   },
   "Results":    [{
         "EmpIdentifier": "1234",
         "AssignedLaborLevelDetails": [{
            "ID": 4381,
            "Messages": ["PASS: Labor Level ID:: '2' was added."],
            "Status": 1
         }],
         "HomeLaborLevelDetails":[{
               "ID": 4382,
               "Messages": ["PASS: Labor Level ID::'6' was added."],
               "Status": 1
            },
            {
               "ID": 4383,
               "Messages": ["PASS: Labor Level ID::'7' was added."],
               "Status": 1
            }
         ]
      },
      {
         "EmpIdentifier": "9999",
         "AssignedLaborLevelDetails": [{
            "ID": 0,
            "Messages": ["FAIL: Invalid EmpIdentifier::9999."],
            "Status": 0
         }],
         "HomeLaborLevelDetails": [{
            "ID": 0,
            "Messages": ["FAIL: Invalid EmpIdentifier::9999."],
            "Status": 0
         }]
      }
   ]
}
SOAP: C# WCF Sample
public void V2_AddUserLaborLevel_SOAP_Test()
{
    try
    {
        var actionTestLogic = new Action<SoapServiceV2.ServiceRouterClient>((client) =>
        {
            List<int> llDetailAssignIds = new List<int>();
            // ==================================
            //TEST 1: ADD
            bool pass = true;
            SoapServiceV2.AddUserLaborLevelRequest request1 = new SoapServiceV2.AddUserLaborLevelRequest();
            List<SoapServiceV2.AddUserLaborLevelModel> payLoad = new List<AddUserLaborLevelModel>();
            List<SoapServiceV2.AddUserAssignedLaborLevelDetails> assignedLaborLevelDetails = new List<AddUserAssignedLaborLevelDetails>();
            AppOne.Core.Security.Token token = new AppOne.Core.Security.Token().GetToken(WSCustomerAlias, WSUserName, WSUserPass, "en-us", AppOne.Core.Security.Token.SourceTypes.WebService);

            //Get a Valid LLDetailId of OrdinalPosition 1 and fetch the LLDetails of that LL 
            LaborLevel laborLevel = new LaborLevel().GetByOrdinalPosition(token, 1);
            LaborLevelDetail llDetail;
            llDetail = laborLevel != null ? new LaborLevelDetail().GetLaborLevelDetailsByLaborLevelID(token, laborLevel.LLID).Where(n => !n.IsDeleted).FirstOrDefault() : null;

            SoapServiceV2.AddUserAssignedLaborLevelDetails assignedLaborLevelDetailsItem = new AddUserAssignedLaborLevelDetails
            {
                ChargeRate = 1.2m,
                EffDate = DateTime.Now,
                ID = llDetail != null ? llDetail.LLDetailID : 0,
                PayRate = 2.2m
            };
            assignedLaborLevelDetails.Add(assignedLaborLevelDetailsItem);
            SoapServiceV2.AddUserLaborLevelModel payLoadItem = new AddUserLaborLevelModel
            {

                EmpIdentifier = "1234",
                AssignedLaborLevelDetails = assignedLaborLevelDetails,
                HomeLaborLevelDetails = new AddUserHomeLaborLevelDetails()
                {
                    LL01EffDate = DateTime.Now,
                    LL01ID = llDetail != null ? llDetail.LLDetailID : 0,
                }
            };

            payLoad.Add(payLoadItem);
            request1.input = new SoapServiceV2.AddUserLaborLevelIn
            {
                AuthToken = AuthToken,
                Payload = payLoad
            };
            SoapServiceV2.AddUserLaborLevelResponse response1 = client.AddUserLaborLevel(request1);
            pass = (response1.AddUserLaborLevelResult.Results != null && response1.AddUserLaborLevelResult.Results.Any(l => l.Status == AddResultStatus.Success)) ? true : false;
            Assert.IsTrue(pass);

            //Get llDetailAssign ID and remove
            llDetailAssignIds.Add(response1.AddUserLaborLevelResult.Results.Where(s => s.ID != 0).Select(s => s.ID).SingleOrDefault());
            DeleteLLDetailAssigns(token, llDetailAssignIds);
        });

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