public FindAllItemReponse <MainScholarshipModel> FindByUserID(string userID)
 {
     try
     {
         IMainScholarshipRepository mainScholarshipRepository = RepositoryClassFactory.GetInstance().GetMainScholarshipRepository();
         IMailingAddressRepository  mailingRepository         = RepositoryClassFactory.GetInstance().GetMailingAddressRepository();
         IUserSubmissionRepository  userSubmissionRepository  = RepositoryClassFactory.GetInstance().GetUserSubmissionRepository();
         IList <MainScholarship>    scholarships = mainScholarshipRepository.FindByUserID(userID);
         var _scholarships = scholarships.Select(n => MapperUtil.CreateMapper().Mapper.Map <MainScholarship, MainScholarshipModel>(n)).ToList();
         if (_scholarships != null)
         {
             IList <MailingAddress> _mailings    = mailingRepository.FindByUserID(userID);
             IList <UserSubmission> _submissions = userSubmissionRepository.FindByUserID(userID);
             foreach (var item in _scholarships)
             {
                 if (_mailings != null && _mailings.Count > 0)
                 {
                     item.RegistrationNumber = _mailings.FirstOrDefault().RegistrationNumber;
                 }
                 if (_submissions != null && _submissions.Count > 0)
                 {
                     item.SubmissionNumber = _submissions.FirstOrDefault().SubmissionNumber;
                 }
             }
         }
         return(new FindAllItemReponse <MainScholarshipModel>
         {
             Items = _scholarships,
             ErrorCode = (int)ErrorCode.None,
             Message = string.Empty
         });
     }
     catch (Exception ex)
     {
         return(new FindAllItemReponse <MainScholarshipModel>
         {
             ErrorCode = (int)ErrorCode.Error,
             Message = ex.Message
         });
     }
 }
 public DataModel.Response.FindItemReponse <DataModel.Model.MainScholarshipModel> FindByID(string id)
 {
     try
     {
         IMainScholarshipRepository mainScholarshipRepository = RepositoryClassFactory.GetInstance().GetMainScholarshipRepository();
         MainScholarship            scholarship = mainScholarshipRepository.FindByID(id);
         var _scholarship = MapperUtil.CreateMapper().Mapper.Map <MainScholarship, MainScholarshipModel>(scholarship);
         if (_scholarship != null)
         {
             IMailingAddressRepository mailingRepository        = RepositoryClassFactory.GetInstance().GetMailingAddressRepository();
             IUserSubmissionRepository userSubmissionRepository = RepositoryClassFactory.GetInstance().GetUserSubmissionRepository();
             IList <MailingAddress>    _mailings    = mailingRepository.FindByUserID(_scholarship.UserID);
             IList <UserSubmission>    _submissions = userSubmissionRepository.FindByUserID(_scholarship.UserID);
             if (_mailings != null && _mailings.Count > 0)
             {
                 _scholarship.RegistrationNumber = _mailings.FirstOrDefault().RegistrationNumber;
             }
             if (_submissions != null && _submissions.Count > 0)
             {
                 _scholarship.SubmissionNumber = _submissions.FirstOrDefault().SubmissionNumber;
             }
         }
         return(new FindItemReponse <MainScholarshipModel>
         {
             Item = _scholarship,
             ErrorCode = (int)ErrorCode.None,
             Message = string.Empty
         });
     }
     catch (Exception ex)
     {
         return(new FindItemReponse <MainScholarshipModel>
         {
             ErrorCode = (int)ErrorCode.Error,
             Message = ex.Message
         });
     }
 }
Esempio n. 3
0
 public FindAllItemReponse <UserSubmissionModel> FindByUserID(string userID)
 {
     try
     {
         IUserSubmissionRepository submissionRepository = RepositoryClassFactory.GetInstance().GetUserSubmissionRepository();
         IList <UserSubmission>    submissions          = submissionRepository.FindByUserID(userID);
         var _submissions = submissions.Select(n => MapperUtil.CreateMapper().Mapper.Map <UserSubmission, UserSubmissionModel>(n)).ToList();
         return(new FindAllItemReponse <UserSubmissionModel>
         {
             Items = _submissions,
             ErrorCode = (int)ErrorCode.None,
             Message = string.Empty
         });
     }
     catch (Exception ex)
     {
         return(new FindAllItemReponse <UserSubmissionModel>
         {
             ErrorCode = (int)ErrorCode.Error,
             Message = ex.Message
         });
     }
 }