Ejemplo n.º 1
0
        public async Task <ActionResult> GetProjects(int page = 1, int pageSize = 20, string projectName = "")
        {
            string token  = Request.Headers["Authorization"];
            var    userID = JWTExtensions.GetDecodeTokenByProperty(token, "nameid").ToInt();

            return(Ok(await _projectService.GetProjects(userID, page, pageSize, projectName)));
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> DeleteRoot(string jobName)
        {
            string token  = Request.Headers["Authorization"];
            var    userID = JWTExtensions.GetDecodeTokenByProperty(token, "nameid").ToInt();

            return(Ok(await _taskService.DeleteRoot(jobName, userID)));
        }
Ejemplo n.º 3
0
        public async Task <IActionResult> SortBy(Data.Enum.Status status)
        {
            string token  = Request.Headers["Authorization"];
            var    userID = JWTExtensions.GetDecodeTokenByProperty(token, "nameid").ToInt();

            return(Ok(await _taskService.TodolistSortBy(status, userID)));
        }
Ejemplo n.º 4
0
        public async Task <IActionResult> GetListTreeTask(string sort = "", string priority = "", string start = "", string end = "", string weekdays = "", string monthly = "", string quarterly = "")
        {
            string token  = Request.Headers["Authorization"];
            var    userID = JWTExtensions.GetDecodeTokenByProperty(token, "nameid").ToInt();

            return(Ok(await _taskService.GetListTree(sort, priority, userID, start, end, weekdays, monthly, quarterly)));
        }
Ejemplo n.º 5
0
        public async Task <IActionResult> GetListUser(int projectid = 0)
        {
            string token  = Request.Headers["Authorization"];
            var    userID = JWTExtensions.GetDecodeTokenByProperty(token, "nameid").ToInt();

            return(Ok(await _taskService.GetListUser(userID, projectid)));
        }
Ejemplo n.º 6
0
        public async Task <IActionResult> Done(int id)
        {
            string token  = Request.Headers["Authorization"];
            string url    = $"{Request.Headers["Origin"]}/#/follow/";
            var    userID = JWTExtensions.GetDecodeTokenByProperty(token, "nameid").ToInt();
            var    model  = await _taskService.Done(id, userID);

            if (model.Item1)
            {
                await _hubContext.Clients.All.SendAsync("ReceiveMessage", model.Item3, "message");

                return(Ok(new
                {
                    status = model.Item1,
                    message = "The task was finished!!!"
                }));
            }
            else if (!model.Item1)
            {
                return(Ok(new {
                    status = model.Item1,
                    message = model.Item3
                }));
            }
            else
            {
                return(Ok(new
                {
                    status = model.Item1,
                    message = "Server error!"
                }));
            }
        }
Ejemplo n.º 7
0
        public async Task <IActionResult> GetListTreeProjectDetail(string sort = "", string priority = "")
        {
            string token  = Request.Headers["Authorization"];
            var    userID = JWTExtensions.GetDecodeTokenByProperty(token, "nameid").ToInt();

            return(Ok(await _taskService.GetListTreeProjectDetail(sort, priority, userID)));
        }
Ejemplo n.º 8
0
        public async Task <IActionResult> GetListTreeHistory(string start, string end)
        {
            string token  = Request.Headers["Authorization"];
            var    userID = JWTExtensions.GetDecodeTokenByProperty(token, "nameid").ToInt();

            return(Ok(await _taskService.GetListTreeHistory(userID, start, end)));
        }
Ejemplo n.º 9
0
        public async Task <IActionResult> Follow(int taskid)
        {
            string token  = Request.Headers["Authorization"];
            var    userID = JWTExtensions.GetDecodeTokenByProperty(token, "nameid").ToInt();

            return(Ok(await _taskService.Follow(userID, taskid)));
        }
Ejemplo n.º 10
0
        public async Task <IActionResult> GetListTreeAbnormal(int ocid = 0, string priority = "", string start = "", string end = "", string weekdays = "")
        {
            string token  = Request.Headers["Authorization"];
            var    userID = JWTExtensions.GetDecodeTokenByProperty(token, "nameid").ToInt();

            return(Ok(await _taskService.GetListTreeAbnormal(ocid, priority, userID, start, end, weekdays)));
        }
Ejemplo n.º 11
0
        public async Task <IActionResult> Routine(int ocid, string sort = "", string priority = "")
        {
            string token  = Request.Headers["Authorization"];
            var    userID = JWTExtensions.GetDecodeTokenByProperty(token, "nameid").ToInt();

            return(Ok(await _taskService.Routine(sort, priority, userID, ocid)));
        }
Ejemplo n.º 12
0
        public async Task <IActionResult> LoadFollow(string sort = "", string priority = "")
        {
            string token  = Request.Headers["Authorization"];
            var    userID = JWTExtensions.GetDecodeTokenByProperty(token, "nameid").ToInt();
            var    OCID   = JWTExtensions.GetDecodeTokenByProperty(token, "OCID").ToInt();

            return(Ok((await _taskService.GetListTreeFollow(sort, priority, userID)).Where(x => "Yes".Equals(x.Follow)).ToList()));
        }
Ejemplo n.º 13
0
        public async Task <IActionResult> UpdateTask([FromBody] UpdateTaskViewModel createTask)
        {
            string token  = Request.Headers["Authorization"];
            var    userID = JWTExtensions.GetDecodeTokenByProperty(token, "nameid").ToInt();

            createTask.CurrentUser = userID;
            return(Ok(await _taskService.UpdateTask(createTask)));
        }
Ejemplo n.º 14
0
        public async Task <IActionResult> LoadTaskHistory(string name, int page, int pageSize)
        {
            string token  = Request.Headers["Authorization"];
            var    userID = JWTExtensions.GetDecodeTokenByProperty(token, "nameid").ToInt();
            var    OCID   = JWTExtensions.GetDecodeTokenByProperty(token, "OCID").ToInt();

            return(Ok(await _taskService.LoadTaskHistory(name, userID, OCID, page, pageSize)));
        }
Ejemplo n.º 15
0
        public async Task <IActionResult> TaskListIsLate()
        {
            string token  = Request.Headers["Authorization"];
            var    userID = JWTExtensions.GetDecodeTokenByProperty(token, "nameid").ToInt();

            //await _taskService.TaskListIsLate(userID);
            return(Ok(201));
        }
Ejemplo n.º 16
0
        public async Task <ActionResult <Project> > Create(Project project)
        {
            string token  = Request.Headers["Authorization"];
            var    userID = JWTExtensions.GetDecodeTokenByProperty(token, "nameid").ToInt();

            project.CreatedBy = userID;
            return(Ok(await _projectService.Create(project)));
        }
Ejemplo n.º 17
0
        public async Task <IActionResult> Add(AddCommentViewModel comment)
        {
            string token  = Request.Headers["Authorization"];
            var    userID = JWTExtensions.GetDecodeTokenByProperty(token, "nameid").ToInt();
            var    model  = await _commentService.Add(comment, userID);

            // await _hubContext.Clients.All.SendAsync("ReceiveMessage", model.Item2, "message");
            return(Ok(model.Item3));
        }
Ejemplo n.º 18
0
        public async Task <ActionResult> Search([FromQuery] PaginationParams param, string projectName)
        {
            string token  = Request.Headers["Authorization"];
            var    userID = JWTExtensions.GetDecodeTokenByProperty(token, "nameid").ToInt();
            var    lists  = await _projectService.GetAllPaging(userID, param.PageNumber, param.PageSize, projectName);

            Response.AddPagination(lists.CurrentPage, lists.PageSize, lists.TotalCount, lists.TotalPages);
            return(Ok(lists));
        }
Ejemplo n.º 19
0
        public async Task <IActionResult> RoutineChild(string taskCode)
        {
            string token  = Request.Headers["Authorization"];
            var    userID = JWTExtensions.GetDecodeTokenByProperty(token, "nameid").ToInt();

            if (userID == 0)
            {
                return(NotFound());
            }
            return(Ok(await _taskService.RoutineChild(taskCode, userID)));
        }
Ejemplo n.º 20
0
        public async Task <IActionResult> GetNotificationByUser(int page, int pageSize, int userid)
        {
            string token  = Request.Headers["Authorization"];
            var    userID = JWTExtensions.GetDecodeTokenByProperty(token, "nameid").ToInt();

            if (userid > 0)
            {
                userID = userid;
            }
            return(Ok(await _notificationService.GetNotificationByUser(userID, page, pageSize)));
        }
Ejemplo n.º 21
0
        public async Task <ActionResult> AddMember(AddMemberViewModel project)
        {
            string token  = Request.Headers["Authorization"];
            var    userID = JWTExtensions.GetDecodeTokenByProperty(token, "nameid").ToInt();

            project.UserID = userID;
            var model = await _projectService.AddMember(project);

            await _hubContext.Clients.All.SendAsync("ReceiveMessage", model.Item2, "message");

            return(Ok(model.Item1));
        }
Ejemplo n.º 22
0
        //Xóa Brand
        public async Task <bool> Delete(object id)
        {
            var    glue   = _repoGlue.FindById(id);
            string token  = _accessor.HttpContext.Request.Headers["Authorization"];
            var    userID = JWTExtensions.GetDecodeTokenByProperty(token, "nameid").ToInt();

            // _repoGlue.Remove(glue);
            glue.isShow       = false;
            glue.ModifiedBy   = userID;
            glue.ModifiedDate = DateTime.Now;
            return(await _repoGlue.SaveAll());
        }
Ejemplo n.º 23
0
        public async Task <IActionResult> CreateTask([FromBody] CreateTaskViewModel createTask)
        {
            string token  = Request.Headers["Authorization"];
            var    userID = JWTExtensions.GetDecodeTokenByProperty(token, "nameid").ToInt();

            createTask.CreatedBy = userID;
            createTask.FromWhoID = userID;
            createTask.UserID    = userID;
            var model = await _taskService.CreateTask(createTask);

            //  await _hubContext.Clients.All.SendAsync("ReceiveMessage", model.Item2, model.Item3);
            // await _hubContext.Clients.All.SendAsync("ReceiveAlertMessage", model.Item2, model.Item3);
            return(Ok(model.Item1));
        }
Ejemplo n.º 24
0
        public async Task <ActionResult> GetAllPaging(int page, int pageSize, string keyword)
        {
            string token  = Request.Headers["Authorization"];
            var    userID = JWTExtensions.GetDecodeTokenByProperty(token, "nameid").ToInt();
            var    model  = await _projectService.GetAllPaging(userID, page, pageSize, keyword);

            return(Ok(new
            {
                data = model,
                total = model.TotalPages,
                page,
                pageSize
            }));
        }
Ejemplo n.º 25
0
        public async Task <IActionResult> SortBy(string assigned)
        {
            string token  = Request.Headers["Authorization"];
            var    userID = JWTExtensions.GetDecodeTokenByProperty(token, "nameid").ToInt();

            if (!assigned.IsNullOrEmpty() && assigned == "Assigned")
            {
                return(Ok(await _taskService.GetListTree("", assigned, userID)));
            }
            else
            {
                return(Ok(await _taskService.GetListTree(assigned, "", userID)));
            }
        }
Ejemplo n.º 26
0
        public async Task <IActionResult> Remark([FromBody] RemarkViewModel remark)
        {
            string token  = Request.Headers["Authorization"];
            var    userID = JWTExtensions.GetDecodeTokenByProperty(token, "nameid").ToInt();

            remark.UserID = userID;
            var model = await _taskService.Remark(remark);

            //Co followed thi moi thong bao
            if (model.Item2)
            {
                await _hubContext.Clients.All.SendAsync("ReceiveMessage", model.Item3, "message");
            }

            return(Ok(model.Item1));
        }
Ejemplo n.º 27
0
        public async Task <IActionResult> ChangeAvatar([FromForm] IFormFile formFile)
        {
            IFormFile file           = Request.Form.Files["UploadedFile"];
            string    token          = Request.Headers["Authorization"];
            var       userID         = JWTExtensions.GetDecodeTokenByProperty(token, "nameid").ToInt();
            string    uniqueFileName = null;

            if (file != null)
            {
                string uploadFolder = Path.Combine(_currentEnvironment.WebRootPath, "images");
                uniqueFileName = Guid.NewGuid().ToString() + '_' + file.FileName;
                var filePath = Path.Combine(uploadFolder, uniqueFileName);
                file.CopyTo(new FileStream(filePath, FileMode.Create));
            }
            return(Ok(await _userService.ChangeAvatar(userID, uniqueFileName)));
        }
Ejemplo n.º 28
0
        //Xóa Supplier
        public async Task <bool> Delete(object id)
        {
            string token  = _accessor.HttpContext.Request.Headers["Authorization"];
            var    userID = JWTExtensions.GetDecodeTokenByProperty(token, "nameid").ToInt();

            if (userID == 0)
            {
                return(false);
            }
            var supplier = _repoSupplier.FindById(id);

            supplier.isShow       = false;
            supplier.ModifiedBy   = userID;
            supplier.ModifiedDate = DateTime.Now;
            return(await _repoSupplier.SaveAll());
        }
Ejemplo n.º 29
0
        //Cập nhật Supplier
        public async Task <bool> Update(SuppilerDto model)
        {
            string token  = _accessor.HttpContext.Request.Headers["Authorization"];
            var    userID = JWTExtensions.GetDecodeTokenByProperty(token, "nameid").ToInt();

            if (userID == 0)
            {
                return(false);
            }
            var supplier = _mapper.Map <Supplier>(model);

            supplier.isShow       = true;
            supplier.ModifiedBy   = userID;
            supplier.ModifiedDate = DateTime.Now;
            _repoSupplier.Update(supplier);
            return(await _repoSupplier.SaveAll());
        }
Ejemplo n.º 30
0
        public async Task <IActionResult> UploapProfile(IFormFile formFile)
        {
            string token  = Request.Headers["Authorization"];
            var    userID = JWTExtensions.GetDecodeTokenByProperty(token, "nameid").ToInt();

            byte[]    image = null;
            IFormFile file  = Request.Form.Files["UploadedFile"];

            if ((file != null) && (file.Length > 0) && !string.IsNullOrEmpty(file.FileName))
            {
                using (var stream = new MemoryStream())
                {
                    await file.CopyToAsync(stream);

                    image = stream.ToArray();
                };
            }
            return(Ok(await _userService.UploapProfile(userID, image)));
        }