/// <summary>
        /// Solve SHIFT problem Endpoint for solving shift optimisation problem.
        /// </summary>
        /// <exception cref="IO.Swagger.Client.ApiException">Thrown when fails to make API call</exception>
        /// <param name="body">Optional description in *Markdown*</param>
        /// <param name="seconds">The number of seconds you give the solver to optimise the SHIFT problem. By default, the solver decides. (optional)</param>
        /// <returns>Task of StatusJob</returns>
        public async System.Threading.Tasks.Task <StatusJob> SolveShiftProblemAsync(ShiftRequest body, int?seconds = null)
        {
            ApiResponse <StatusJob> localVarResponse = await SolveShiftProblemAsyncWithHttpInfo(body, seconds);

            return(localVarResponse.Data);
        }
        /// <summary>
        /// Solve SHIFT problem Endpoint for solving shift optimisation problem.
        /// </summary>
        /// <exception cref="IO.Swagger.Client.ApiException">Thrown when fails to make API call</exception>
        /// <param name="body">Optional description in *Markdown*</param>
        /// <param name="seconds">The number of seconds you give the solver to optimise the SHIFT problem. By default, the solver decides. (optional)</param>
        /// <returns>Task of ApiResponse (StatusJob)</returns>
        public async System.Threading.Tasks.Task <ApiResponse <StatusJob> > SolveShiftProblemAsyncWithHttpInfo(ShiftRequest body, int?seconds = null)
        {
            // verify the required parameter 'body' is set
            if (body == null)
            {
                throw new ApiException(400, "Missing required parameter 'body' when calling ShiftApi->SolveShiftProblem");
            }

            var    localVarPath         = "/solve";
            var    localVarPathParams   = new Dictionary <String, String>();
            var    localVarQueryParams  = new List <KeyValuePair <String, String> >();
            var    localVarHeaderParams = new Dictionary <String, String>(this.Configuration.DefaultHeader);
            var    localVarFormParams   = new Dictionary <String, String>();
            var    localVarFileParams   = new Dictionary <String, FileParameter>();
            Object localVarPostBody     = null;

            // to determine the Content-Type header
            String[] localVarHttpContentTypes = new String[] {
                "application/json"
            };
            String localVarHttpContentType = this.Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes);

            // to determine the Accept header
            String[] localVarHttpHeaderAccepts = new String[] {
                "application/json"
            };
            String localVarHttpHeaderAccept = this.Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts);

            if (localVarHttpHeaderAccept != null)
            {
                localVarHeaderParams.Add("Accept", localVarHttpHeaderAccept);
            }

            if (seconds != null)
            {
                localVarQueryParams.AddRange(this.Configuration.ApiClient.ParameterToKeyValuePairs("", "seconds", seconds));                  // query parameter
            }
            if (body != null && body.GetType() != typeof(byte[]))
            {
                localVarPostBody = this.Configuration.ApiClient.Serialize(body); // http body (model) parameter
            }
            else
            {
                localVarPostBody = body; // byte array
            }

            // authentication (basicAuth) required
            // http basic authentication required
            if (!String.IsNullOrEmpty(this.Configuration.Username) || !String.IsNullOrEmpty(this.Configuration.Password))
            {
                localVarHeaderParams["Authorization"] = "Basic " + ApiClient.Base64Encode(this.Configuration.Username + ":" + this.Configuration.Password);
            }
            // authentication (bearerAuth) required

            // make the HTTP request
            IRestResponse localVarResponse = (IRestResponse)await this.Configuration.ApiClient.CallApiAsync(localVarPath,
                                                                                                            Method.POST, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarFileParams,
                                                                                                            localVarPathParams, localVarHttpContentType);

            int localVarStatusCode = (int)localVarResponse.StatusCode;

            if (ExceptionFactory != null)
            {
                Exception exception = ExceptionFactory("SolveShiftProblem", localVarResponse);
                if (exception != null)
                {
                    throw exception;
                }
            }

            return(new ApiResponse <StatusJob>(localVarStatusCode,
                                               localVarResponse.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()),
                                               (StatusJob)this.Configuration.ApiClient.Deserialize(localVarResponse, typeof(StatusJob))));
        }
        /// <summary>
        /// Solve SHIFT problem Endpoint for solving shift optimisation problem.
        /// </summary>
        /// <exception cref="IO.Swagger.Client.ApiException">Thrown when fails to make API call</exception>
        /// <param name="body">Optional description in *Markdown*</param>
        /// <param name="seconds">The number of seconds you give the solver to optimise the SHIFT problem. By default, the solver decides. (optional)</param>
        /// <returns>StatusJob</returns>
        public StatusJob SolveShiftProblem(ShiftRequest body, int?seconds = null)
        {
            ApiResponse <StatusJob> localVarResponse = SolveShiftProblemWithHttpInfo(body, seconds);

            return(localVarResponse.Data);
        }
Exemplo n.º 4
0
        public void ToStringTest()
        {
            ShiftRequest sr = new ShiftRequest(3, 999, "George", "morning", "monday", 1, 1000);

            Assert.AreEqual("Work on monday morning", sr.ToString());
        }
Exemplo n.º 5
0
        public void ShowIdNameTest()
        {
            ShiftRequest sr = new ShiftRequest(3, 999, "George", "morning", "monday", 1, 1000);

            Assert.AreEqual("ID: 999 George", sr.ShowIdName());
        }
Exemplo n.º 6
0
        public void HasWorkedTest()
        {
            ShiftRequest sr = new ShiftRequest(3, 999, "George", "morning", "monday", 1, 1000);

            Assert.IsFalse(sr.HasWorked());
        }
Exemplo n.º 7
0
        public void FindRequestTest()
        {
            RequestsController rc         = new RequestsController();
            UserController     uc         = new UserController();
            MySqlConnection    connection = CreateConnection();

            uc.AddNewUser("Test", "Test", new DateTime(1998, 02, 04), "Eindhoven", Gender.MALE + 1, "12345678", new DateTime(2020, 02, 03),
                          "test", "test", "*****@*****.**", 1000, Role.EMPLOYEE + 1, 1, Department.Accessories.ToString());
            using (connection)
            {
                connection.Open();
                string sql = "INSERT INTO shift_requests(shift_id, user_id, work)" +
                             " VALUES (@shiftID, @userID, @work);";
                using (MySqlCommand cmd = new MySqlCommand(sql, connection))
                {
                    cmd.Parameters.AddWithValue("@shiftID", 1);
                    cmd.Parameters.AddWithValue("@userID", uc.lastInsertedUserId);
                    cmd.Parameters.AddWithValue("@work", 1);
                    cmd.ExecuteNonQuery();
                }
                connection.Close();
            }

            ShiftRequest        expectedRequest = null;
            List <ShiftRequest> allrequests     = rc.LoadShiftRequests();

            foreach (ShiftRequest sr in allrequests)
            {
                if (sr.Fname == "Test")
                {
                    expectedRequest = sr;
                }
            }

            ShiftRequest actualRequest = null;

            if (expectedRequest != null)
            {
                actualRequest = rc.FindRequest(expectedRequest.RequestID);
            }

            using (connection)
            {
                connection.Open();
                string sql1 = "DELETE FROM shift_requests WHERE user_id = @id;";
                using (MySqlCommand cmd = new MySqlCommand(sql1, connection))
                {
                    cmd.Parameters.AddWithValue("@id", uc.lastInsertedUserId);
                    cmd.ExecuteNonQuery();
                }

                string sql2 = "DELETE FROM users WHERE username = @username;";
                using (MySqlCommand cmd = new MySqlCommand(sql2, connection))
                {
                    cmd.Parameters.AddWithValue("@username", "test");
                    cmd.ExecuteNonQuery();
                }
                connection.Close();
            }

            Assert.AreEqual(expectedRequest.RequestID, actualRequest.RequestID);
        }