예제 #1
0
        internal static IEnumerable <JobDetailedViewModel> SearchJob(string queryString)
        {
            var headers = new Dictionary <string, string>();

            headers["X-accessToken"] = AccessToken;

            var matchedJobs =
                HttpRequester.Get <IEnumerable <JobDetailedModel> >(BaseServicesUrl + "jobs/search?query=" + queryString, headers);

            return(matchedJobs.
                   AsQueryable().
                   Select(model => new JobDetailedViewModel()
            {
                Id = model.Id,
                Title = model.Title,
                Description = model.Description,
                //Deadline = model.Deadline,
                //CreatedAt = model.CreatedAt,
                //Completed = model.Completed,
                //Price = model.Price,
                //Tasks = model.Tasks.AsQueryable().Select(todo => new TaskViewModel()
                //{
                //    Id = todo.Id,
                //    Name = todo.Name,
                //    Pending = todo.Pending
                //}).ToList(),
                ////Tasks = model.Tasks,
                //TotalDifficulty = model.TotalDifficulty,
                //Category = model.Category,
                //JobTags = model.JobTags.AsQueryable().Select(tag => tag.Name).ToList()
            }));
        }
예제 #2
0
        internal static IEnumerable <JobDetailedViewModel> GetDetailedMyJobsList()
        {
            var headers = new Dictionary <string, string>();

            headers["X-accessToken"] = AccessToken;

            var jobsList =
                HttpRequester.Get <IEnumerable <JobDetailedModel> >(BaseServicesUrl + "jobs/current-jobs", headers);

            return(jobsList.
                   AsQueryable().
                   Select(model => new JobDetailedViewModel()
            {
                Id = model.Id,
                Title = model.Title,
                Description = model.Description,
                Deadline = model.Deadline,
                CreatedAt = model.CreatedAt,
                Completed = model.Completed,
                Price = model.Price,
                //Tasks = model.Tasks.AsQueryable().Select(todo => new TaskViewModel()
                //{
                //    Id = todo.Id,
                //    Name = todo.Name,
                //    Pending = todo.Pending
                //}).ToList(),
                //Tasks = model.Tasks,
                Owner = model.Owner,
                TotalDifficulty = model.TotalDifficulty,
                Category = model.Category,
                //JobTags = model.JobTags.AsQueryable().Select(tag => tag.Name).ToList()
                // JobTags = model.JobTags
            }));
        }
예제 #3
0
        internal static void ChangeState(int taskId)
        {
            var headers = new Dictionary <string, string>();

            headers["X-accessToken"] = AccessToken;

            HttpRequester.Put(BaseServicesUrl + "tasks/" + taskId, headers);
        }
예제 #4
0
        internal static bool LogoutUser()
        {
            var headers = new Dictionary <string, string>();

            headers["X-accessToken"] = AccessToken;
            var isLogoutSuccessful = HttpRequester.Put(BaseServicesUrl + "users/logout", headers);

            return(isLogoutSuccessful);
        }
예제 #5
0
        internal static string LoginUser(string username, string authenticationCode)
        {
            ValidateUsername(username);
            ValidateAuthCode(authenticationCode);

            var userModel = new UserLoginModel()
            {
                Username = username,
                AuthCode = authenticationCode
            };
            var loginResponse = HttpRequester.Post <LoginResponseModel>(BaseServicesUrl + "auth/token",
                                                                        userModel);

            AccessToken = loginResponse.AccessToken;
            return(loginResponse.DisplayName);
        }
예제 #6
0
        internal static IEnumerable <JobDetailedViewModel> GetMyJobsList()
        {
            var headers = new Dictionary <string, string>();

            headers["X-accessToken"] = AccessToken;

            var jobsList =
                HttpRequester.Get <IEnumerable <JobDetailedViewModel> >(BaseServicesUrl + "jobs/current-jobs-names", headers);

            return(jobsList.
                   AsQueryable().
                   Select(model => new JobDetailedViewModel()
            {
                Id = model.Id,
                Title = model.Title,
            }));
        }
예제 #7
0
        internal static void RegisterUser(string username, string displayName, string email,
                                          string phone, string location, string authenticationCode)
        {
            ValidateUsername(username);
            ValidateEmail(email);
            ValidateAuthCode(authenticationCode);

            var userModel = new UserModel()
            {
                Username    = username,
                DisplayName = displayName,
                Email       = email,
                Phone       = phone,
                Location    = location,
                AuthCode    = authenticationCode
            };

            HttpRequester.Post(BaseServicesUrl + "users/register",
                               userModel);
        }
예제 #8
0
        internal static void CreateNewTodosList(string title, string description, DateTime deadline, double price,
                                                string category, string totalDifficulty, IEnumerable <TaskViewModel> tasks)
        {
            var listModel = new JobDetailedModel()
            {
                Title           = title,
                Description     = description,
                Deadline        = deadline,
                Price           = price,
                Category        = category,
                TotalDifficulty = totalDifficulty.ToString(),
                Tasks           = tasks.Select(t => new TaskModel()
                {
                    Name       = t.Name,
                    Difficulty = t.Difficulty
                }).ToList()
            };

            var headers = new Dictionary <string, string>();

            headers["X-accessToken"] = AccessToken;

            HttpRequester.Post <JobViewModel>(BaseServicesUrl + "jobs/new", listModel, headers);
        }