public ProblemResourceTask CreateUpdateTask(CreateUpdateProblemResourceTask request, ProblemResource resource = null)
        {
            if (request.ID == 0)
            {
                return(CreateTask(request, resource));
            }

            return(UpdateTask(request));
        }
        public ProblemResourceTask UpdateTask(CreateUpdateProblemResourceTask request)
        {
            if (request.ID == 0)
            {
                return(null);
            }

            var entity = Get(request.ID);

            if (entity == null)
            {
                return(null);
            }

            entity.IsDone = request.IsDone;
            Update(entity);

            return(entity);
        }
        public ProblemResourceTask CreateTask(CreateUpdateProblemResourceTask request, ProblemResource resource)
        {
            if (request.ID != 0)
            {
                return(null);
            }

            if (IsTaskExist(request.Title, resource))
            {
                return(null);
            }

            var entity = new ProblemResourceTask
            {
                Resource = resource,
                Title    = request.Title,
                IsDone   = request.IsDone
            };

            Create(entity);

            return(entity);
        }