Exemplo n.º 1
0
        // GET: TaskList
        public ActionResult GetTaskLists(int currentPageIndex)
        {
            int maxRows = 10;

            try
            {
                User user = _securityManager.GetLoggedUser();
                if (user == null)
                {
                    return(RedirectToAction("NotFound", "Errors"));
                }
                else
                {
                    var taskList = _taskListManager.ListTaskLists(user);

                    var filteredList = (from item in taskList
                                        select item)
                                       .OrderBy(item => item.Id)
                                       .Skip((currentPageIndex - 1) * maxRows)
                                       .Take(maxRows).ToList();

                    double pageCount = (double)((decimal)taskList.Count() / Convert.ToDecimal(maxRows));
                    pageCount         = (int)Math.Ceiling(pageCount);
                    ViewBag.PageCount = pageCount;

                    ViewBag.CurrentPage = currentPageIndex;

                    return(View(filteredList));
                }
            }
            catch (Exception e)
            {
                return(RedirectToAction("NotFound", "Errors"));
            }

            //string apiUrl = "http://localhost:51004/Tasklists";

            //using (HttpClient client = new HttpClient())
            //{

            //    client.BaseAddress = new Uri(apiUrl);
            //    client.DefaultRequestHeaders.Accept.Clear();
            //    client.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json"));

            //    HttpResponseMessage response = await client.GetAsync(apiUrl);
            //    if (response.IsSuccessStatusCode)
            //    {
            //        var data = await response.Content.ReadAsStringAsync();
            //       // var table = Newtonsoft.Json.JsonConvert.DeserializeObject<System.Data.DataTable>(data);
            //        List<TaskList> taskLists = Newtonsoft.Json.JsonConvert.DeserializeObject<List<TaskList>>(data);
            //        return View(taskLists);
            //    }
            //}
        }
Exemplo n.º 2
0
        public void ShowTaskList()
        {
            ListBox taskList = Application.OpenForms["frmMain"].Controls["taskList"] as ListBox;

            User user = _securityManager.GetLoggedUser();
            var  taskListDisplayed = _taskListManager.ListTaskLists(user);

            taskList.DisplayMember = "Name";
            taskList.ValueMember   = "Id";
            taskList.DataSource    = taskListDisplayed;
            taskList.SelectedIndex = -1;
        }
Exemplo n.º 3
0
        public IHttpActionResult GetTaskLists()
        {
            User user = _securityManager.GetLoggedUser();

            try
            {
                List <TaskList> taskLists = _taskListManager.ListTaskLists(user);
                return(Ok(taskLists));
            }
            catch (TaskListException)
            {
                return(ResponseMessage(Request.CreateErrorResponse(HttpStatusCode.NotFound, "Operation failed")));
            }
        }
Exemplo n.º 4
0
        public void ListTaskLists()
        {
            User user = _securityManager.GetLoggedUser();

            Console.Clear();
            Console.WriteLine("Listing available Task Lists: ");
            Console.WriteLine("");
            List <TaskList> listTaskList = _taskListManager.ListTaskLists(user);

            foreach (var row in listTaskList)
            {
                Console.WriteLine(row.Id + " " + row.Name);
            }
            Console.WriteLine("Done");
            MenuOption.TaskListMenu();
        }