示例#1
0
        internal static IEnumerable <TodoListViewModel> GetTodoLists()
        {
            var headers = new Dictionary <string, string>();

            headers["X-accessToken"] = AccessToken;

            var httpRequester = new HttpRequester(BaseServicesUrl);

            var todoListsModels =
                httpRequester.Get <IEnumerable <TodolistModel> >("lists", headers);

            return(todoListsModels.
                   AsQueryable().
                   Select(model => new TodoListViewModel()
            {
                Id = model.Id,
                Title = model.Title,
                Todos = model.Todos.AsQueryable().Select(todo => new TodoViewModel()
                {
                    Id = todo.Id,
                    Text = todo.Text,
                    IsDone = todo.IsDone
                })
            }));
        }
示例#2
0
        internal static bool LogoutUser()
        {
            var headers = new Dictionary <string, string>();

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

            return(isLogoutSuccessful);
        }
示例#3
0
        internal static void ChangeState(int todoId)
        {
            var headers = new Dictionary <string, string>();

            headers["X-accessToken"] = AccessToken;

            var httpRequester = new HttpRequester(BaseServicesUrl);

            httpRequester.Put("todos/" + todoId, headers);
        }
示例#4
0
        internal static IEnumerable <AppointmentViewModel> GetAllAppointments()
        {
            var headers = new Dictionary <string, string>();

            headers["X-accessToken"] = AccessToken;

            var httpRequester = new HttpRequester(BaseServicesUrl);

            return(httpRequester.
                   Get <IEnumerable <AppointmentViewModel> >("appointments/all", headers));
        }
示例#5
0
        internal static void RegisterUser(string username, string email, string authenticationCode)
        {
            //Validation!!!!!
            //validate username
            //validate email
            //validate authentication code
            //use validation from WebAPI
            var userModel = new UserModel()
            {
                Username = username,
                Email    = email,
                AuthCode = authenticationCode
            };
            var httpRequester = new HttpRequester(BaseServicesUrl);

            var response = httpRequester.Post <UserModel>("users/register", userModel);
        }
示例#6
0
        internal static void CreateNewTodosList(string title, IEnumerable <TodoViewModel> todos)
        {
            var listModel = new TodolistModel()
            {
                Title = title,
                Todos = todos.Select(t => new TodoModel()
                {
                    Text = t.Text
                })
            };

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

            headers["X-accessToken"] = AccessToken;

            var httpRequester = new HttpRequester(BaseServicesUrl);

            var response =
                httpRequester.Post <ListCreatedModel>("lists", listModel, headers);
        }
示例#7
0
        internal static string LoginUser(string username, string authenticationCode)
        {
            //Validation!!!!!
            //validate username
            //validate authentication code
            //use validation from WebAPI
            var userModel = new UserModel()
            {
                Username = username,
                AuthCode = authenticationCode
            };

            var httpRequester = new HttpRequester(BaseServicesUrl);

            var loginResponse = httpRequester
                                .Post <LoginResponseModel>("auth/token", userModel);

            AccessToken = loginResponse.AccessToken;
            return(loginResponse.Username);
        }
示例#8
0
        internal static AppointmentModel AddNewAppointment(string subject,
                                                           string description, DateTime appointmentDate, int duration)
        {
            var appointment = new AppointmentModel
            {
                Subject         = subject,
                Description     = description,
                AppointmentDate = appointmentDate.ToString(),
                Duration        = duration
            };

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

            headers["X-accessToken"] = AccessToken;

            var httpRequester = new HttpRequester(BaseServicesUrl);

            var response = httpRequester.Post <AppointmentModel>(
                "appointments/new",
                appointment,
                headers);

            return(response);
        }