Example #1
0
        public bool ChechOutTask(TaskModel task, int issueId)
        {
            if (task == null)
            {
                return(false);
            }

            if (issueId != task.IssueId)
            {
                return(false);
            }

            return(true);
        }
Example #2
0
        public async Task <ActionResult <TaskModel> > GetAsync(string accountId, int idIssue, int id)
        {
            ActionResult <Issue> result = await OneIssueLoadAsync(accountId, idIssue);

            if (result.Result.GetType() != typeof(OkObjectResult))
            {
                return(new BadRequestResult());
            }

            TaskModel taskModel = await _taskDataService.GetAsync(id);

            if (taskModel == null)
            {
                return(new NotFoundResult());
            }
            if (taskModel.IssueId != idIssue)
            {
                return(new BadRequestResult());
            }
            return(new OkObjectResult(taskModel));
        }
Example #3
0
        public async Task <ActionResult <TaskModel> > PutAsync(string accountId, int idIssue, int id, TaskModel task)
        {
            ActionResult <Issue> result = await OneIssueLoadAsync(accountId, idIssue);

            if (result.Result.GetType() != typeof(OkObjectResult))
            {
                return(new BadRequestResult());
            }

            if (!ChechOutTask(task, idIssue))
            {
                return(new BadRequestResult());
            }

            if (id != task.Id)
            {
                return(new BadRequestResult());
            }

            if (!await _taskDataService.IsExistsAsync(task.Id))
            {
                return(new NotFoundResult());
            }

            return(new OkObjectResult(await _taskDataService.UpdateAsync(task)));
        }
Example #4
0
        public async Task <ActionResult <TaskModel> > PostAsync(string accountId, int idIssue, TaskModel task)
        {
            ActionResult <Issue> result = await OneIssueLoadAsync(accountId, idIssue);

            if (result.Result.GetType() != typeof(OkObjectResult))
            {
                return(new BadRequestResult());
            }

            if (!ChechOutTask(task, idIssue))
            {
                return(new BadRequestResult());
            }

            await _taskDataService.CreateAsync(task);

            return(new OkObjectResult(task));
        }