Exemplo n.º 1
0
 public TurkRServiceResponse Post(TurkRServiceRequest request)
 {
     switch(request.Operation.ToLower())
     {
         case "hello":
             return Hello();
         case "checkin":
             return Checkin(request);
         case "checkout":
             return Checkout(request);
         case "getcodes":
             return GetCodes(request);
         case "coordinates":
             return Coordinates(request.Id);
         case "session":
             return Session(request.Id);
         default:
             return NotValid(request);
     }
 }
Exemplo n.º 2
0
 /// <summary>
 /// Just return the request in the response
 /// </summary>
 /// <param name="request"></param>
 /// <returns></returns>
 private TurkRServiceResponse PingPong(TurkRServiceRequest request)
 {
     return new TurkRServiceResponse { Operation = request.Operation, IsValid = false, Result = request };
 }
Exemplo n.º 3
0
 /// <summary>
 /// Standard not authorized response
 /// </summary>
 /// <param name="request">ServiceRequest object</param>
 /// <returns></returns>
 private TurkRServiceResponse NotValid(TurkRServiceRequest request)
 {
     return new TurkRServiceResponse { Operation = request.Operation, IsValid = false, Result = "Request is not valid." };
 }
Exemplo n.º 4
0
 /// <summary>
 /// Standard not authorized response
 /// </summary>
 /// <param name="request">ServiceRequest object</param>
 /// <returns></returns>
 private TurkRServiceResponse NotAuthorized(TurkRServiceRequest request)
 {
     return new TurkRServiceResponse { Operation = request.Operation, IsValid = false, Result = "Not authorized to use the service." };
 }
Exemplo n.º 5
0
        /// <summary>
        /// Returns a list of access and exit codes for a project
        /// </summary>
        /// <param name="request">A TurkR request object</param>
        /// <returns>List of access and exit code</returns>
        private TurkRServiceResponse GetCodes(TurkRServiceRequest request)
        {
            List<TurkR.Web.Api.Models.CodeView> codeList = new List<TurkR.Web.Api.Models.CodeView>();
            codeList.Add(new Models.CodeView { AccessCode = "A1", ExitCode = "E1", IsUsed = false, Status = 0 });
            codeList.Add(new Models.CodeView { AccessCode = "A2", ExitCode = "E2", IsUsed = false, Status = 0 });
            codeList.Add(new Models.CodeView { AccessCode = "A3", ExitCode = "E3", IsUsed = false, Status = 0 });
            codeList.Add(new Models.CodeView { AccessCode = "A4", ExitCode = "E4", IsUsed = false, Status = 0 });
            codeList.Add(new Models.CodeView { AccessCode = "A5", ExitCode = "E5", IsUsed = false, Status = 0 });

            return new TurkRServiceResponse { Operation = "GetCodes", Id = request.AccessCode, Result = codeList, IsValid = true };
        }
Exemplo n.º 6
0
 /// <summary>
 /// Performs a checkout from the remote site
 /// </summary>
 /// <param name="request"></param>
 /// <returns></returns>
 private TurkRServiceResponse Checkout(TurkRServiceRequest request)
 {
     return new TurkRServiceResponse { Operation = "Checkout", Id = request.AccessCode, Result = true, IsValid = true };
 }