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 }); } }
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.BaseResponse Delete(string id) { try { IUserSubmissionRepository submissionRepository = RepositoryClassFactory.GetInstance().GetUserSubmissionRepository(); submissionRepository.Delete(id); return(new BaseResponse { ErrorCode = (int)ErrorCode.None, Message = Resources.Resource.msg_delete_success }); } catch (Exception ex) { return(new BaseResponse { ErrorCode = (int)ErrorCode.Error, Message = ex.Message }); } }
public DataModel.Response.BaseResponse Update(DataModel.Model.UserSubmissionModel submission) { try { IUserSubmissionRepository submissionRepository = RepositoryClassFactory.GetInstance().GetUserSubmissionRepository(); var _submission = MapperUtil.CreateMapper().Mapper.Map <UserSubmissionModel, UserSubmission>(submission); submissionRepository.Update(_submission); return(new BaseResponse { ErrorCode = (int)ErrorCode.None, Message = Resources.Resource.msg_update_success }); } catch (Exception ex) { return(new BaseResponse { 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 }); } }
public DataModel.Response.FindItemReponse <DataModel.Model.UserSubmissionModel> FindByID(string id) { try { IUserSubmissionRepository submissionRepository = RepositoryClassFactory.GetInstance().GetUserSubmissionRepository(); UserSubmission submission = submissionRepository.FindByID(id); 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 }); } }
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 }); } }
public GetSubmissionByIdQueryHandler(IUserSubmissionRepository submissionRepository) { _submissionRepository = submissionRepository; }