Exemplo n.º 1
0
        //returns "MODEL.Submission" object if successful/found
        //returns "null" if not
        internal Submission findSubmissionBySubmissionId(int submissionId)
        {
            int        result     = (int)CODE.MINUS_ONE;
            Submission submission = null;

            //validate submissionId
            if (
                result == (int)CODE.ZERO ||
                string.IsNullOrWhiteSpace(submissionId.ToString()) ||
                !Validate.isAllNumbers(submissionId.ToString()) ||
                !Validate.integerIsBiggerThan(submissionId, (int)CODE.TRANSLATO_DATABASE_SEED - 1)
                )
            {
                result = (int)CODE.ZERO;
            }
            if (result != (int)CODE.ZERO)//safe to proceed
            {
                ISubmissions _DbSubmission = new DbSubmissions();

                try
                {
                    using (var trScope = TransactionScopeBuilder.CreateSerializable())
                    {
                        submission = _DbSubmission.findSubmissionBySubmissionId(submissionId);

                        trScope.Complete();
                    }
                }
                catch (TransactionAbortedException taEx)
                {
                    result = (int)CODE.ZERO;
                    Log.Add(taEx.ToString());
                }
                catch (ApplicationException aEx)
                {
                    result = (int)CODE.ZERO;
                    Log.Add(aEx.ToString());
                }
                catch (Exception ex)
                {
                    result = (int)CODE.ZERO;
                    Log.Add(ex.ToString());
                }
            }
            else
            {
                result = (int)CODE.ZERO;
            }

            if (result == (int)CODE.ZERO || submission == null)
            {
                return(null);
            }
            else
            {
                return(submission);
            }
        }