Beispiel #1
0
        public async Task <IActionResult> Index()
        {
            var model    = new FriendsViewModel();
            var requests = await _client.Get <IEnumerable <UserFriendBL> >("api/friendrequests");

            model.friendRequests = requests.Select(fr => new FriendViewModel()
            {
                FriendId   = fr.FriendId,
                AddDate    = fr.AddDate,
                FamilyName = fr.Friend.FamilyName,
                Name       = fr.Friend.Name,
                UserName   = fr.Friend.UserName,
                Photo      = fr.Friend.Photo
            }).ToList();

            var friends = await _client.Get <IEnumerable <UserFriendBL> >("api/friends");

            model.friends = friends.Select(fr => new FriendViewModel()
            {
                AddDate    = fr.AddDate,
                FriendId   = fr.FriendId,
                FamilyName = fr.Friend.FamilyName,
                Name       = fr.Friend.Name,
                UserName   = fr.Friend.UserName,
                Photo      = fr.Friend.Photo
            }).ToList();

            var editRequests = await _taskClient.Get <IEnumerable <TaskEditGrantsBL> >("api/mytaskfriendgrant/list");

            model.editRequests = editRequests.Select(er => new FriendEditRequestViewModel()
            {
                TaskId     = er.TaskId,
                FriendId   = er.FriendId,
                FamilyName = friends.FirstOrDefault(fr => fr.FriendId == er.FriendId).Friend.FamilyName,
                Name       = friends.FirstOrDefault(fr => fr.FriendId == er.FriendId).Friend.Name,
                UserName   = friends.FirstOrDefault(fr => fr.FriendId == er.FriendId).Friend.UserName,
                Photo      = friends.FirstOrDefault(fr => fr.FriendId == er.FriendId).Friend.Photo,
                AddDate    = er.date
            }).ToList();

            return(View(model));
        }
 private string GetTheaters(int id)
 {
     return(_apiClient.Get(new Uri($"{_configuration["Theaters:BaseUrl"]}{_configuration["Theaters:MethodTheaterName"]}{id}")));
 }
Beispiel #3
0
 public string Pay(string user, double total)
 {
     return(_apiClient.Get(new Uri($"{_paymentSettings.Url}/{user}/{total}")));
 }
Beispiel #4
0
        public async Task <IActionResult> Index(string start, string end, bool?delay, bool?completed, int categoryId, int priorityId, string pattern, int page = 1, string tagName = "")
        {
            IEnumerable <TaskModelBL> tasks = await _client.Get <List <TaskModelBL> >("api/mytask/list");

            List <MyTaskViewModel> viewModels = new List <MyTaskViewModel>();

            if (tasks != null)
            {
                foreach (var task in tasks)
                {
                    MyTaskViewModel viewModel = new MyTaskViewModel
                    {
                        Id             = task.Id,
                        Name           = task.Name,
                        StartDate      = task.StartDate,
                        TargetDate     = task.TargetDate,
                        EndDate        = task.EndDate,
                        Details        = task.Details,
                        IsRepeating    = task.IsRepeating,
                        TaskСategoryId = task.TaskСategoryId,
                        TaskPriorityId = task.TaskPriorityId,
                        ParentTaskId   = task.ParentTaskId,
                        files          = null,
                        IsFriendTask   = task.IsFriendTask
                    };
                    if (task.EndDate == null && completed != true)
                    {
                        viewModels.Add(viewModel);
                    }
                    if (task.EndDate != null && completed == true)
                    {
                        viewModels.Add(viewModel);
                    }

                    List <TaskTagModelBL> taskTag = await _client.Get <List <TaskTagModelBL> >("api/tasktag/fortask/" + task.Id.ToString());

                    if (taskTag != null)
                    {
                        viewModel.Tags = new List <TagInfoViewModel>();
                        foreach (TaskTagModelBL fl in taskTag)
                        {
                            viewModel.Tags.Add(new TagInfoViewModel()
                            {
                                Id   = fl.Id,
                                Name = fl.Name
                            });
                        }
                    }
                }
            }
            if (delay == true)
            {
                viewModels = _filterService.FilterTasksByDelay(viewModels);
            }
            if (start != null)
            {
                viewModels = _filterService.FilterTasksByDate(viewModels, start, end);
            }
            if (pattern != null && !pattern.Contains("#"))
            {
                viewModels = _filterService.FilterTasksByName(viewModels, pattern);
            }
            if (categoryId != 0)
            {
                viewModels = _filterService.FilterTasksByCategory(viewModels, categoryId);
            }
            if (priorityId != 0)
            {
                viewModels = _filterService.FilterTasksByPriority(viewModels, priorityId);
            }
            if (!string.IsNullOrEmpty(tagName) || (pattern != null && pattern.Contains("#")))
            {
                viewModels = _filterService.FilterTasksByTagName(viewModels, string.IsNullOrEmpty(tagName) ? pattern.Replace("#", "") : tagName);
            }

            List <TaskCategoryModelBL> categories = await _client.Get <List <TaskCategoryModelBL> >("api/taskcategory");

            List <PriorityModelBL> priorities = await _client.Get <List <PriorityModelBL> >("api/priority");

            categories.Insert(0, new TaskCategoryModelBL {
                Name = "", Id = 0
            });
            priorities.Insert(0, new PriorityModelBL {
                Name = "", Id = 0
            });

            ViewBag.Categories = new SelectList(categories, "Id", "Name");
            ViewBag.Priorities = new SelectList(priorities, "Id", "Name");

            PageMyTaskViewModel pageViewModel = new PageMyTaskViewModel(viewModels.Count, page, PageSize);

            IndexMyTaskViewModel indexViewModel = new IndexMyTaskViewModel()
            {
                MyTasks       = viewModels.Skip((page - 1) * PageSize).Take(PageSize).ToList(),
                PageViewModel = pageViewModel
            };

            if (start != null)
            {
                indexViewModel.StartDate = Convert.ToDateTime(start);
            }

            if (end != null)
            {
                indexViewModel.EndDate = Convert.ToDateTime(end);
            }

            if (delay != null)
            {
                indexViewModel.Delay = delay;
            }

            if (completed != null)
            {
                indexViewModel.Completed = completed;
            }

            if (pattern != null && !pattern.Contains("#"))
            {
                indexViewModel.Pattern = pattern;
            }

            if (categoryId != 0)
            {
                indexViewModel.CategoryId = categoryId;
            }

            if (priorityId != 0)
            {
                indexViewModel.PriorityId = priorityId;
            }

            return(View(indexViewModel));
        }
Beispiel #5
0
        public async Task <FileResult> Index(int taskid, string filename)
        {
            var model = await _client.Get <FileModelBL>($"api/myfiles/{taskid}/{filename}");

            return(File(model.Data, model.ContentType));
        }