//LAYER_Class_nameOfTheMethod_TestedScenario_ExpectedBehaviour public void BLL_CtrUser_insertUser_InsertUser_UserIsInserted() { //arrange int userId = 1; string userName = "******"; string hashedPassword = "******"; string firstName = "Adrian"; string lastName = "Frunza"; string email = "*****@*****.**"; bool newsletterOptOut = false; DateTimeOffset createdOn = DateTimeOffset.Now; User user_m1 = new User( userId, userName, hashedPassword, firstName, lastName, email, newsletterOptOut, createdOn ); CtrUser _CtrUser = new CtrUser(); //act int result = _CtrUser.insertUser(user_m1); //assert // Assert.AreEqual(1, result, "user not inserted"); Assert.IsTrue(result>=(int)ENUM.CODE.TRANSLATO_DATABASE_SEED); }
//LAYER_Class_nameOfTheMethod_TestedScenario_ExpectedBehaviour public void BLL_CtrUser_findUserById_FindExistingUserById_UserObjectIsReturned() { //arrange int userId = 1000000; //change to a valid one before running the test CtrUser _CtrUser = new CtrUser(); //act User user = _CtrUser.findUserByUserId(userId); //assert Assert.IsNotNull(user); }
public ReturnedObject insertUser(string publicKey, string privateKey, User user) { ReturnedObject returnedObject = new ReturnedObject(); if (Security.authorizeClient(publicKey, privateKey)) { CtrUser _CtrUser = new CtrUser(); returnedObject.code = _CtrUser.insertUser(user); } else { returnedObject.code = (int)CODE.CLIENT_NOT_AUTHORIZED; } return returnedObject; }
public ReturnedObject loginUser(string publicKey, string privateKey, string userNameOrEmail, string HRpassword) { ReturnedObject returnedObject = new ReturnedObject(); if (Security.authorizeClient(publicKey, privateKey)) { CtrUser _CtrUser = new CtrUser(); returnedObject.code = _CtrUser.loginUser(userNameOrEmail, HRpassword); } else { returnedObject.code = (int)CODE.CLIENT_NOT_AUTHORIZED; } return returnedObject; }
//returns [int >= TRANSLATO_DATABASE_SEED] if successful //returns [int < TRANSLATO_DATABASE_SEED] if not private int insertJob(Job job, bool isText, bool isFile) { if ((isText && isFile) || (!isText && !isFile)) { return((int)CODE.CTRJOB_INSERTJOB_ISBOTHORNEITHER); //means the functions was called wrong } int returnCode = (int)CODE.ZERO; int result = (int)CODE.MINUS_ONE; //validate jobName if ( result == (int)CODE.ZERO || returnCode != (int)CODE.ZERO || string.IsNullOrWhiteSpace(job.jobName) || !Validate.isAlphaNumericWithUnderscoreAndSpaceAndDash(job.jobName) || !Validate.hasMaxLength(job.jobName, 50) || !Validate.hasMinLength(job.jobName, 1) ) { if (isText) { returnCode = (int)CODE.CTRJOB_INSERTJOBTEXT_INVALID_JOBNAME; } result = (int)CODE.ZERO; if (isFile) { returnCode = (int)CODE.CTRJOB_INSERTJOBFILE_INVALID_JOBNAME; } result = (int)CODE.ZERO; } //validate dateCreated if ( result == (int)CODE.ZERO || returnCode != (int)CODE.ZERO //nothing to validate here at this point ) { if (isText) { returnCode = (int)CODE.CTRJOB_INSERTJOBTEXT_INVALID_DATECREATED; } result = (int)CODE.ZERO; if (isFile) { returnCode = (int)CODE.CTRJOB_INSERTJOBFILE_INVALID_DATECREATED; } result = (int)CODE.ZERO; } //validate durationInDays if ( result == (int)CODE.ZERO || returnCode != (int)CODE.ZERO || job.durationInDays.Equals(null) || !Validate.integerIsBiggerThan(job.durationInDays, 0) || !Validate.integerIsSmallerThan(job.durationInDays, 32) ) { if (isText) { returnCode = (int)CODE.CTRJOB_INSERTJOBTEXT_INVALID_DURATIONINDAYS; } result = (int)CODE.ZERO; if (isFile) { returnCode = (int)CODE.CTRJOB_INSERTJOBFILE_INVALID_DURATIONINDAYS; } result = (int)CODE.ZERO; } //validate reward if ( result == (int)CODE.ZERO || returnCode != (int)CODE.ZERO || job.reward.Equals(null) || !Validate.decimalIsBiggerThan(job.reward, 0) ) { if (isText) { returnCode = (int)CODE.CTRJOB_INSERTJOBTEXT_INVALID_REWARD; } result = (int)CODE.ZERO; if (isFile) { returnCode = (int)CODE.CTRJOB_INSERTJOBFILE_INVALID_REWARD; } result = (int)CODE.ZERO; } //validate dateAwarded if ( result == (int)CODE.ZERO || returnCode != (int)CODE.ZERO //nothing to validate here at this point ) { if (isText) { returnCode = (int)CODE.CTRJOB_INSERTJOBTEXT_INVALID_DATEAWARDED; } result = (int)CODE.ZERO; if (isFile) { returnCode = (int)CODE.CTRJOB_INSERTJOBFILE_INVALID_DATEAWARDED; } result = (int)CODE.ZERO; } //validate languageFrom //has to exist CtrLanguage _CtrLanguageFrom = new CtrLanguage(); if ( result == (int)CODE.ZERO || returnCode != (int)CODE.ZERO || job.languageFrom.Equals(null) || _CtrLanguageFrom.findLanguageByLanguageId(job.languageFrom.languageId) == null ) { if (isText) { returnCode = (int)CODE.CTRJOB_INSERTJOBTEXT_INVALID_LANGUAGEFROM; } result = (int)CODE.ZERO; if (isFile) { returnCode = (int)CODE.CTRJOB_INSERTJOBFILE_INVALID_LANGUAGEFROM; } result = (int)CODE.ZERO; } //validate languageTo //has to exist CtrLanguage _CtrLanguageTo = new CtrLanguage(); if ( result == (int)CODE.ZERO || returnCode != (int)CODE.ZERO || job.languageTo.Equals(null) || _CtrLanguageTo.findLanguageByLanguageId(job.languageTo.languageId) == null ) { if (isText) { returnCode = (int)CODE.CTRJOB_INSERTJOBTEXT_INVALID_LANGUAGETO; } result = (int)CODE.ZERO; if (isFile) { returnCode = (int)CODE.CTRJOB_INSERTJOBFILE_INVALID_LANGUAGETO; } result = (int)CODE.ZERO; } //validate user //has to exist CtrUser _CtrUser = new CtrUser(); if ( result == (int)CODE.ZERO || returnCode != (int)CODE.ZERO || job.user.Equals(null) || _CtrUser.findUserByUserId(job.user.userId) == null ) { if (isText) { returnCode = (int)CODE.CTRJOB_INSERTJOBTEXT_INVALID_USER; } result = (int)CODE.ZERO; if (isFile) { returnCode = (int)CODE.CTRJOB_INSERTJOBFILE_INVALID_USER; } result = (int)CODE.ZERO; } //validate upload //does not have to exist; will be created if ( result == (int)CODE.ZERO || returnCode != (int)CODE.ZERO || job.upload.Equals(null) ) { if (isText) { returnCode = (int)CODE.CTRJOB_INSERTJOBTEXT_INVALID_UPLOAD; } result = (int)CODE.ZERO; if (isFile) { returnCode = (int)CODE.CTRJOB_INSERTJOBFILE_INVALID_UPLOAD; } result = (int)CODE.ZERO; } if (returnCode == (int)CODE.ZERO && result != (int)CODE.ZERO)//safe to proceed { job.jobName = job.jobName; job.dateCreated = DateTimeOffset.Now; job.durationInDays = job.durationInDays; job.reward = job.reward; job.dateAwarded = null; job.languageFrom = job.languageFrom; job.languageTo = job.languageTo; job.user = job.user; job.upload = job.upload; CtrUpload _CtrUpload = new CtrUpload(); IJobs _DbJobs = new DbJobs(); try { using (var trScope = TransactionScopeBuilder.CreateSerializable()) { if (isText) { returnCode = _CtrUpload.insertUploadText(job.upload); } if (isFile) { returnCode = _CtrUpload.insertUploadFile(job.upload); } if (returnCode >= (int)CODE.TRANSLATO_DATABASE_SEED)//means upload was inserted successfully { job.upload.uploadId = returnCode; returnCode = _DbJobs.insertJob(job); } else {//means upload failed to be inserted trScope.Dispose(); } trScope.Complete(); } } catch (TransactionAbortedException taEx) { if (isText) { returnCode = (int)CODE.CTRJOB_INSERTJOBTEXT_EXCEPTION; } if (isFile) { returnCode = (int)CODE.CTRJOB_INSERTJOBFILE_EXCEPTION; } Log.Add(taEx.ToString()); } catch (ApplicationException aEx) { if (isText) { returnCode = (int)CODE.CTRJOB_INSERTJOBTEXT_EXCEPTION; } if (isFile) { returnCode = (int)CODE.CTRJOB_INSERTJOBFILE_EXCEPTION; } Log.Add(aEx.ToString()); } catch (Exception ex) { if (isText) { returnCode = (int)CODE.CTRJOB_INSERTJOBTEXT_EXCEPTION; } if (isFile) { returnCode = (int)CODE.CTRJOB_INSERTJOBFILE_EXCEPTION; } Log.Add(ex.ToString()); } } else { } return(returnCode); }
//returns [int >= TRANSLATO_DATABASE_SEED] if successful //returns [int < TRANSLATO_DATABASE_SEED] if not private int insertJob(Job job, bool isText, bool isFile) { if ((isText && isFile) || (!isText && !isFile)) return (int)CODE.CTRJOB_INSERTJOB_ISBOTHORNEITHER;//means the functions was called wrong int returnCode = (int)CODE.ZERO; int result = (int)CODE.MINUS_ONE; //validate jobName if ( result == (int)CODE.ZERO || returnCode != (int)CODE.ZERO || string.IsNullOrWhiteSpace(job.jobName) || !Validate.isAlphaNumericWithUnderscoreAndSpaceAndDash(job.jobName) || !Validate.hasMaxLength(job.jobName, 50) || !Validate.hasMinLength(job.jobName, 1) ) { if (isText) returnCode = (int)CODE.CTRJOB_INSERTJOBTEXT_INVALID_JOBNAME; result = (int)CODE.ZERO; if (isFile) returnCode = (int)CODE.CTRJOB_INSERTJOBFILE_INVALID_JOBNAME; result = (int)CODE.ZERO; } //validate dateCreated if ( result == (int)CODE.ZERO || returnCode != (int)CODE.ZERO //nothing to validate here at this point ) { if (isText) returnCode = (int)CODE.CTRJOB_INSERTJOBTEXT_INVALID_DATECREATED; result = (int)CODE.ZERO; if (isFile) returnCode = (int)CODE.CTRJOB_INSERTJOBFILE_INVALID_DATECREATED; result = (int)CODE.ZERO; } //validate durationInDays if ( result == (int)CODE.ZERO || returnCode != (int)CODE.ZERO || job.durationInDays.Equals(null) || !Validate.integerIsBiggerThan(job.durationInDays, 0) || !Validate.integerIsSmallerThan(job.durationInDays, 32) ) { if (isText) returnCode = (int)CODE.CTRJOB_INSERTJOBTEXT_INVALID_DURATIONINDAYS; result = (int)CODE.ZERO; if (isFile) returnCode = (int)CODE.CTRJOB_INSERTJOBFILE_INVALID_DURATIONINDAYS; result = (int)CODE.ZERO; } //validate reward if ( result == (int)CODE.ZERO || returnCode != (int)CODE.ZERO || job.reward.Equals(null) || !Validate.decimalIsBiggerThan(job.reward, 0) ) { if (isText) returnCode = (int)CODE.CTRJOB_INSERTJOBTEXT_INVALID_REWARD; result = (int)CODE.ZERO; if (isFile) returnCode = (int)CODE.CTRJOB_INSERTJOBFILE_INVALID_REWARD; result = (int)CODE.ZERO; } //validate dateAwarded if ( result == (int)CODE.ZERO || returnCode != (int)CODE.ZERO //nothing to validate here at this point ) { if (isText) returnCode = (int)CODE.CTRJOB_INSERTJOBTEXT_INVALID_DATEAWARDED; result = (int)CODE.ZERO; if (isFile) returnCode = (int)CODE.CTRJOB_INSERTJOBFILE_INVALID_DATEAWARDED; result = (int)CODE.ZERO; } //validate languageFrom //has to exist CtrLanguage _CtrLanguageFrom = new CtrLanguage(); if ( result == (int)CODE.ZERO || returnCode != (int)CODE.ZERO || job.languageFrom.Equals(null) || _CtrLanguageFrom.findLanguageByLanguageId(job.languageFrom.languageId) == null ) { if (isText) returnCode = (int)CODE.CTRJOB_INSERTJOBTEXT_INVALID_LANGUAGEFROM; result = (int)CODE.ZERO; if (isFile) returnCode = (int)CODE.CTRJOB_INSERTJOBFILE_INVALID_LANGUAGEFROM; result = (int)CODE.ZERO; } //validate languageTo //has to exist CtrLanguage _CtrLanguageTo = new CtrLanguage(); if ( result == (int)CODE.ZERO || returnCode != (int)CODE.ZERO || job.languageTo.Equals(null) || _CtrLanguageTo.findLanguageByLanguageId(job.languageTo.languageId) == null ) { if (isText) returnCode = (int)CODE.CTRJOB_INSERTJOBTEXT_INVALID_LANGUAGETO; result = (int)CODE.ZERO; if (isFile) returnCode = (int)CODE.CTRJOB_INSERTJOBFILE_INVALID_LANGUAGETO; result = (int)CODE.ZERO; } //validate user //has to exist CtrUser _CtrUser = new CtrUser(); if ( result == (int)CODE.ZERO || returnCode != (int)CODE.ZERO || job.user.Equals(null) || _CtrUser.findUserByUserId(job.user.userId) == null ) { if (isText) returnCode = (int)CODE.CTRJOB_INSERTJOBTEXT_INVALID_USER; result = (int)CODE.ZERO; if (isFile) returnCode = (int)CODE.CTRJOB_INSERTJOBFILE_INVALID_USER; result = (int)CODE.ZERO; } //validate upload //does not have to exist; will be created if ( result == (int)CODE.ZERO || returnCode != (int)CODE.ZERO || job.upload.Equals(null) ) { if (isText) returnCode = (int)CODE.CTRJOB_INSERTJOBTEXT_INVALID_UPLOAD; result = (int)CODE.ZERO; if (isFile) returnCode = (int)CODE.CTRJOB_INSERTJOBFILE_INVALID_UPLOAD; result = (int)CODE.ZERO; } if (returnCode == (int)CODE.ZERO && result != (int)CODE.ZERO)//safe to proceed { job.jobName = job.jobName; job.dateCreated = DateTimeOffset.Now; job.durationInDays = job.durationInDays; job.reward = job.reward; job.dateAwarded = null; job.languageFrom = job.languageFrom; job.languageTo = job.languageTo; job.user = job.user; job.upload = job.upload; CtrUpload _CtrUpload = new CtrUpload(); IJobs _DbJobs = new DbJobs(); try { using (var trScope = TransactionScopeBuilder.CreateSerializable()) { if (isText) returnCode = _CtrUpload.insertUploadText(job.upload); if (isFile) returnCode = _CtrUpload.insertUploadFile(job.upload); if (returnCode >= (int)CODE.TRANSLATO_DATABASE_SEED)//means upload was inserted successfully { job.upload.uploadId = returnCode; returnCode = _DbJobs.insertJob(job); } else {//means upload failed to be inserted trScope.Dispose(); } trScope.Complete(); } } catch (TransactionAbortedException taEx) { if (isText) returnCode = (int)CODE.CTRJOB_INSERTJOBTEXT_EXCEPTION; if (isFile) returnCode = (int)CODE.CTRJOB_INSERTJOBFILE_EXCEPTION; Log.Add(taEx.ToString()); } catch (ApplicationException aEx) { if (isText) returnCode = (int)CODE.CTRJOB_INSERTJOBTEXT_EXCEPTION; if (isFile) returnCode = (int)CODE.CTRJOB_INSERTJOBFILE_EXCEPTION; Log.Add(aEx.ToString()); } catch (Exception ex) { if (isText) returnCode = (int)CODE.CTRJOB_INSERTJOBTEXT_EXCEPTION; if (isFile) returnCode = (int)CODE.CTRJOB_INSERTJOBFILE_EXCEPTION; Log.Add(ex.ToString()); } } else { } return returnCode; }
//returns [int >= TRANSLATO_DATABASE_SEED] if successful //returns [int < TRANSLATO_DATABASE_SEED] if not private int insertSubmission(Submission submission, bool isText, bool isFile) { if ((isText && isFile) || (!isText && !isFile)) { return((int)CODE.CTRSUBMISSION_INSERTSUBMISSION_ISBOTHORNEITHER); //means the functions was called wrong } int returnCode = (int)CODE.ZERO; int result = (int)CODE.MINUS_ONE; //validate dateSubmitted if ( result == (int)CODE.ZERO || returnCode != (int)CODE.ZERO //nothing to validate here at this point ) { if (isText) { returnCode = (int)CODE.CTRSUBMISSION_INSERTSUBMISSIONTEXT_INVALID_DATESUBMITTED; } result = (int)CODE.ZERO; if (isFile) { returnCode = (int)CODE.CTRSUBMISSION_INSERTSUBMISSIONFILE_INVALID_DATESUBMITTED; } result = (int)CODE.ZERO; } //validate isAwarded if ( result == (int)CODE.ZERO || returnCode != (int)CODE.ZERO //nothing to validate here at this point ) { if (isText) { returnCode = (int)CODE.CTRSUBMISSION_INSERTSUBMISSIONTEXT_INVALID_ISAWARDED; } result = (int)CODE.ZERO; if (isFile) { returnCode = (int)CODE.CTRSUBMISSION_INSERTSUBMISSIONFILE_INVALID_ISAWARDED; } result = (int)CODE.ZERO; } //validate user //has to exist CtrUser _CtrUser = new CtrUser(); if ( result == (int)CODE.ZERO || returnCode != (int)CODE.ZERO || submission.user.Equals(null) || _CtrUser.findUserByUserId(submission.user.userId) == null ) { if (isText) { returnCode = (int)CODE.CTRSUBMISSION_INSERTSUBMISSIONTEXT_INVALID_USER; } result = (int)CODE.ZERO; if (isFile) { returnCode = (int)CODE.CTRSUBMISSION_INSERTSUBMISSIONFILE_INVALID_USER; } result = (int)CODE.ZERO; } //validate upload //does not have to exist; will be created if ( result == (int)CODE.ZERO || returnCode != (int)CODE.ZERO || submission.upload.Equals(null) ) { if (isText) { returnCode = (int)CODE.CTRSUBMISSION_INSERTSUBMISSIONTEXT_INVALID_UPLOAD; } result = (int)CODE.ZERO; if (isFile) { returnCode = (int)CODE.CTRSUBMISSION_INSERTSUBMISSIONFILE_INVALID_UPLOAD; } result = (int)CODE.ZERO; } //validate job //has to exist CtrJob _CtrJob = new CtrJob(); if ( result == (int)CODE.ZERO || returnCode != (int)CODE.ZERO || submission.job.Equals(null) || _CtrJob.findJobByJobId(submission.job.jobId) == null ) { if (isText) { returnCode = (int)CODE.CTRSUBMISSION_INSERTSUBMISSIONTEXT_INVALID_JOB; } result = (int)CODE.ZERO; if (isFile) { returnCode = (int)CODE.CTRSUBMISSION_INSERTSUBMISSIONFILE_INVALID_JOB; } result = (int)CODE.ZERO; } if (returnCode == (int)CODE.ZERO && result != (int)CODE.ZERO)//safe to proceed { submission.dateSubmitted = DateTimeOffset.Now; submission.isAwarded = false; submission.user = submission.user; submission.upload = submission.upload; submission.job = submission.job; CtrUpload _CtrUpload = new CtrUpload(); ISubmissions _DbSubmissions = new DbSubmissions(); try { using (var trScope = TransactionScopeBuilder.CreateSerializable()) { if (isText) { returnCode = _CtrUpload.insertUploadText(submission.upload); } if (isFile) { returnCode = _CtrUpload.insertUploadFile(submission.upload); } if (returnCode >= (int)CODE.TRANSLATO_DATABASE_SEED)//means upload was inserted successfully { submission.upload.uploadId = returnCode; returnCode = _DbSubmissions.insertSubmission(submission); } else {//means upload failed to be inserted trScope.Dispose(); } trScope.Complete(); } } catch (TransactionAbortedException taEx) { if (isText) { returnCode = (int)CODE.CTRSUBMISSION_INSERTSUBMISSIONTEXT_EXCEPTION; } if (isFile) { returnCode = (int)CODE.CTRSUBMISSION_INSERTSUBMISSIONFILE_EXCEPTION; } Log.Add(taEx.ToString()); } catch (ApplicationException aEx) { if (isText) { returnCode = (int)CODE.CTRSUBMISSION_INSERTSUBMISSIONTEXT_EXCEPTION; } if (isFile) { returnCode = (int)CODE.CTRSUBMISSION_INSERTSUBMISSIONFILE_EXCEPTION; } Log.Add(aEx.ToString()); } catch (Exception ex) { if (isText) { returnCode = (int)CODE.CTRSUBMISSION_INSERTSUBMISSIONTEXT_EXCEPTION; } if (isFile) { returnCode = (int)CODE.CTRSUBMISSION_INSERTSUBMISSIONFILE_EXCEPTION; } Log.Add(ex.ToString()); } } else { } return(returnCode); }
//returns [int >= TRANSLATO_DATABASE_SEED] if successful //returns [int < TRANSLATO_DATABASE_SEED] if not private int insertSubmission(Submission submission, bool isText, bool isFile) { if ((isText && isFile) || (!isText && !isFile)) return (int)CODE.CTRSUBMISSION_INSERTSUBMISSION_ISBOTHORNEITHER;//means the functions was called wrong int returnCode = (int)CODE.ZERO; int result = (int)CODE.MINUS_ONE; //validate dateSubmitted if ( result == (int)CODE.ZERO || returnCode != (int)CODE.ZERO //nothing to validate here at this point ) { if (isText) returnCode = (int)CODE.CTRSUBMISSION_INSERTSUBMISSIONTEXT_INVALID_DATESUBMITTED; result = (int)CODE.ZERO; if (isFile) returnCode = (int)CODE.CTRSUBMISSION_INSERTSUBMISSIONFILE_INVALID_DATESUBMITTED; result = (int)CODE.ZERO; } //validate isAwarded if ( result == (int)CODE.ZERO || returnCode != (int)CODE.ZERO //nothing to validate here at this point ) { if (isText) returnCode = (int)CODE.CTRSUBMISSION_INSERTSUBMISSIONTEXT_INVALID_ISAWARDED; result = (int)CODE.ZERO; if (isFile) returnCode = (int)CODE.CTRSUBMISSION_INSERTSUBMISSIONFILE_INVALID_ISAWARDED; result = (int)CODE.ZERO; } //validate user //has to exist CtrUser _CtrUser = new CtrUser(); if ( result == (int)CODE.ZERO || returnCode != (int)CODE.ZERO || submission.user.Equals(null) || _CtrUser.findUserByUserId(submission.user.userId) == null ) { if (isText) returnCode = (int)CODE.CTRSUBMISSION_INSERTSUBMISSIONTEXT_INVALID_USER; result = (int)CODE.ZERO; if (isFile) returnCode = (int)CODE.CTRSUBMISSION_INSERTSUBMISSIONFILE_INVALID_USER; result = (int)CODE.ZERO; } //validate upload //does not have to exist; will be created if ( result == (int)CODE.ZERO || returnCode != (int)CODE.ZERO || submission.upload.Equals(null) ) { if (isText) returnCode = (int)CODE.CTRSUBMISSION_INSERTSUBMISSIONTEXT_INVALID_UPLOAD; result = (int)CODE.ZERO; if (isFile) returnCode = (int)CODE.CTRSUBMISSION_INSERTSUBMISSIONFILE_INVALID_UPLOAD; result = (int)CODE.ZERO; } //validate job //has to exist CtrJob _CtrJob = new CtrJob(); if ( result == (int)CODE.ZERO || returnCode != (int)CODE.ZERO || submission.job.Equals(null) || _CtrJob.findJobByJobId(submission.job.jobId) == null ) { if (isText) returnCode = (int)CODE.CTRSUBMISSION_INSERTSUBMISSIONTEXT_INVALID_JOB; result = (int)CODE.ZERO; if (isFile) returnCode = (int)CODE.CTRSUBMISSION_INSERTSUBMISSIONFILE_INVALID_JOB; result = (int)CODE.ZERO; } if (returnCode == (int)CODE.ZERO && result != (int)CODE.ZERO)//safe to proceed { submission.dateSubmitted = DateTimeOffset.Now; submission.isAwarded = false; submission.user = submission.user; submission.upload = submission.upload; submission.job = submission.job; CtrUpload _CtrUpload = new CtrUpload(); ISubmissions _DbSubmissions = new DbSubmissions(); try { using (var trScope = TransactionScopeBuilder.CreateSerializable()) { if (isText) returnCode = _CtrUpload.insertUploadText(submission.upload); if (isFile) returnCode = _CtrUpload.insertUploadFile(submission.upload); if (returnCode >= (int)CODE.TRANSLATO_DATABASE_SEED)//means upload was inserted successfully { submission.upload.uploadId = returnCode; returnCode = _DbSubmissions.insertSubmission(submission); } else {//means upload failed to be inserted trScope.Dispose(); } trScope.Complete(); } } catch (TransactionAbortedException taEx) { if (isText) returnCode = (int)CODE.CTRSUBMISSION_INSERTSUBMISSIONTEXT_EXCEPTION; if (isFile) returnCode = (int)CODE.CTRSUBMISSION_INSERTSUBMISSIONFILE_EXCEPTION; Log.Add(taEx.ToString()); } catch (ApplicationException aEx) { if (isText) returnCode = (int)CODE.CTRSUBMISSION_INSERTSUBMISSIONTEXT_EXCEPTION; if (isFile) returnCode = (int)CODE.CTRSUBMISSION_INSERTSUBMISSIONFILE_EXCEPTION; Log.Add(aEx.ToString()); } catch (Exception ex) { if (isText) returnCode = (int)CODE.CTRSUBMISSION_INSERTSUBMISSIONTEXT_EXCEPTION; if (isFile) returnCode = (int)CODE.CTRSUBMISSION_INSERTSUBMISSIONFILE_EXCEPTION; Log.Add(ex.ToString()); } } else { } return returnCode; }