Пример #1
0
 public DataModel.Response.InsertResponse Create(DataModel.Model.UserSubmissionModel submission)
 {
     try
     {
         IUserSubmissionRepository submissionRepository = RepositoryClassFactory.GetInstance().GetUserSubmissionRepository();
         var item = submissionRepository.FindBySubmissionNumber(submission.SubmissionNumber);
         if (item != null)
         {
             return(new InsertResponse
             {
                 ErrorCode = (int)ErrorCode.Error,
                 Message = string.Format(Resources.Resource.msg_insert_exists, "The submission number", submission.SubmissionNumber)
             });
         }
         var    _submission = MapperUtil.CreateMapper().Mapper.Map <UserSubmissionModel, UserSubmission>(submission);
         object id          = submissionRepository.Insert(_submission);
         return(new InsertResponse
         {
             InsertID = id.ToString(),
             ErrorCode = (int)ErrorCode.None,
             Message = Resources.Resource.msg_create_success
         });
     }
     catch (Exception ex)
     {
         return(new InsertResponse
         {
             ErrorCode = (int)ErrorCode.Error,
             Message = ex.Message
         });
     }
 }
Пример #2
0
 public FindItemReponse <UserSubmissionModel> FindBySubmissionNumber(string submissionNumber)
 {
     try
     {
         IUserSubmissionRepository submissionRepository = RepositoryClassFactory.GetInstance().GetUserSubmissionRepository();
         UserSubmission            submission           = submissionRepository.FindBySubmissionNumber(submissionNumber);
         var _submission = MapperUtil.CreateMapper().Mapper.Map <UserSubmission, UserSubmissionModel>(submission);
         return(new FindItemReponse <UserSubmissionModel>
         {
             Item = _submission,
             ErrorCode = (int)ErrorCode.None,
             Message = string.Empty
         });
     }
     catch (Exception ex)
     {
         return(new FindItemReponse <UserSubmissionModel>
         {
             ErrorCode = (int)ErrorCode.Error,
             Message = ex.Message
         });
     }
 }