Exemplo n.º 1
0
        public IEnumerable <TaskTagModelBL> GetTagByTaskId(int taskId)
        {
            try
            {
                if (taskId <= 0)
                {
                    throw new ArgumentNullException();
                }
                if (!checkUserService.AccessGrantedForUser(taskId))
                {
                    throw new UnauthorizedAccessException();
                }

                IEnumerable <TaskTag> tagForTasks = context.TaskTags.GetAll().Where(t => t.MyTaskId == taskId);
                List <TaskTagModelBL> taskTagList = new List <TaskTagModelBL>();

                foreach (var taskTag in tagForTasks)
                {
                    taskTagList.Add(new TaskTagModelBL()
                    {
                        Id     = taskTag.TagId,
                        Name   = GetAll().FirstOrDefault(t => t.Id == taskTag.TagId).Name,
                        TaskId = taskTag.MyTaskId
                    });
                }

                return(taskTagList);
            }
            catch (Exception)
            {
                throw;
            }
        }
        public void UpdateCategoryForTask(int taskId, string UserId, bool IsAdmin, TaskCategoryModelBL taskCategory)
        {
            try
            {
                if (taskId <= 0 || taskCategory == null)
                {
                    throw new ArgumentNullException();
                }
                if (!checkUserService.AccessGrantedForUser(taskId))
                {
                    throw new UnauthorizedAccessException();
                }

                MyTask myTask = context.MyTasks.GetAll().FirstOrDefault(t => t.Id == taskId);

                if (myTask == null)
                {
                    throw new ArgumentNullException();
                }

                myTask.TaskСategoryId = taskCategory.Id;

                context.MyTasks.Update(myTask);
                context.SaveChanges();
            }
            catch (Exception)
            {
                throw;
            }
        }
Exemplo n.º 3
0
        public IEnumerable <FileModelBL> GetAll(int TaskId)
        {
            if (!HttpContextExtensions.IsAdmin(httpContext) && !checkUserService.AccessGrantedForUser(TaskId))
            {
                return(null);
            }

            var idlist = context.TasksFiles.Where(tf => tf.TaskId == TaskId).Select(tf => tf.FileId);
            var list   = context.Files.Where(t => idlist.Contains(t.Id));

            return(list.Select(file => new FileModelBL()
            {
                Id = file.Id,
                FileName = file.FileName,
                ContentType = file.ContentType,
                Data = null // тело файла для списка не нужно
            }));
        }