Ejemplo n.º 1
0
        public bool SetComposition <TEntity>(ICollection <TEntity> collection, string propertyName, long?propertyValue, bool autoIncrement)
            where TEntity : class
        {
            var result       = new List <TEntity>();
            var resultStatus = true;

            if (collection != null)
            {
                foreach (var entity in collection)
                {
                    try
                    {
                        if ((ImplementationUtil.ContainsProperty(entity.GetType(), propertyName) && 0 == (long)MapperUtil.GetValue(entity, propertyName)) ||
                            (ImplementationUtil.ContainsInterface(entity.GetType(), nameof(IEntityState)) && !((IEntityState)entity).IsExists))
                        {
                            if (propertyValue.HasValue && !string.IsNullOrWhiteSpace(propertyName))
                            {
                                MapperUtil.SetValue(entity, propertyName, propertyValue);
                            }
                            if (Insert(entity, autoIncrement) > 0)
                            {
                                result.Add(entity);
                            }
                        }
                        else if (((IAssociationOfData)entity).IsKeep && Update(entity))
                        {
                            result.Add(entity);
                        }
                        else
                        {
                            Delete(entity);
                        }
                    }
                    catch (SQLException ex)
                    {
                        resultStatus = false;
                        throw ex;
                    }
                }
            }

            collection = result;
            return(resultStatus);
        }
Ejemplo n.º 2
0
        public ConfigModel GetConfig()
        {
            ConfigModel ret = new ConfigModel();

            using (var db = new SmartTSqlDB())
            {
                var res = db.TConfigs.ToList();
                ret.Name           = GetConfigStr(res, "TName");
                ret.MenuStr        = GetConfigStr(res, "MenuStr");
                ret.PrivateMenuStr = GetConfigStr(res, "PMenuStr");
                ret.MasterQQ       = GetConfigStr(res, "MasterQQ");
                var funcs = db.TFuncconfigs.ToList();
                funcs.ForEach(p =>
                {
                    ret.FunList.Add(MapperUtil.Map <FuncItem>(p));
                });
                return(ret);
            }
        }
Ejemplo n.º 3
0
        public bool SaveOrUpdate <TEntity>(TEntity entity, string keyName, long?value)
            where TEntity : class
        {
            var result = false;

            if (entity != null)
            {
                try
                {
                    if (IsUpdate(entity, keyName))
                    {
                        result = Update(entity);
                    }
                    else
                    {
                        var oldValue = (long)MapperUtil.GetValue(entity, keyName);
                        try
                        {
                            if (value.HasValue && value.Value != oldValue)
                            {
                                MapperUtil.SetValue(entity, keyName, value);
                            }
                            result = Save(entity, keyName, !value.HasValue);
                        }
                        catch (Exception)
                        {
                            if (value.HasValue && value.Value != oldValue)
                            {
                                MapperUtil.SetValue(entity, keyName, oldValue);
                            }
                            throw;
                        }
                    }
                }
                catch (Exception ex)
                {
                    result = false;
                    throw ex;
                }
            }
            return(result);
        }
 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
         });
     }
 }
Ejemplo n.º 5
0
 public DataModel.Response.BaseResponse Update(DataModel.Model.LeaderShipModel leadership)
 {
     try
     {
         ILeaderShipRepository leaderShipRepository = RepositoryClassFactory.GetInstance().GetLeaderShipRepository();
         var _leadership = MapperUtil.CreateMapper().Mapper.Map <LeaderShipModel, LeaderShip>(leadership);
         leaderShipRepository.Update(_leadership);
         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
         });
     }
 }
Ejemplo n.º 6
0
 public InsertResponse CreateMenu(MenuModel menu)
 {
     try
     {
         IMenuRepository menuRepository = RepositoryClassFactory.GetInstance().GetMenuRepository();
         Menu            _menu          = null;
         if (string.IsNullOrEmpty(menu.ParentID))
         {
             _menu = menuRepository.FindParentByTitle(menu.Title, menu.Language);
         }
         else
         {
             _menu = menuRepository.FindByTitleAndParent(menu.Title, menu.ParentID);
         }
         if (_menu != null)
         {
             return(new InsertResponse
             {
                 ErrorCode = (int)ErrorCode.Error,
                 Message = string.Format(Resources.Resource.msg_insert_exists, Resources.Resource.text_category_title, menu.Title)
             });
         }
         object id = menuRepository.Insert(MapperUtil.CreateMapper().Mapper.Map <MenuModel, Menu>(menu));
         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
         });
     }
 }
Ejemplo n.º 7
0
 public BaseResponse UpdateAdmin(AdminModel admin)
 {
     try
     {
         IAdminRepository adminRepository = RepositoryClassFactory.GetInstance().GetAdminRepository();
         Admin            _admin          = MapperUtil.CreateMapper().Mapper.Map <AdminModel, Admin>(admin);
         adminRepository.Update(_admin);
         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
         });
     }
 }
Ejemplo n.º 8
0
 public DataModel.Response.BaseResponse UpdateSlider(DataModel.Model.SliderModel slider)
 {
     try
     {
         ISliderRepository sliderRepository = RepositoryClassFactory.GetInstance().GetSliderRepository();
         Slider            _slider          = MapperUtil.CreateMapper().Mapper.Map <SliderModel, Slider>(slider);
         sliderRepository.Update(_slider);
         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.InsertResponse CreateMailingAddress(DataModel.Model.MailingAddressModel mailing)
 {
     try
     {
         IMailingAddressRepository mailingRepository = RepositoryClassFactory.GetInstance().GetMailingAddressRepository();
         object id = mailingRepository.Insert(MapperUtil.CreateMapper().Mapper.Map <MailingAddressModel, MailingAddress>(mailing));
         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
         });
     }
 }
Ejemplo n.º 10
0
 public DataModel.Response.BaseResponse UpdateArticle(DataModel.Model.ArticleModel article)
 {
     try
     {
         IArticleRepository articleRepository = RepositoryClassFactory.GetInstance().GetArticleRepository();
         Article            _article          = MapperUtil.CreateMapper().Mapper.Map <ArticleModel, Article>(article);
         articleRepository.Update(_article);
         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
         });
     }
 }
Ejemplo n.º 11
0
 public DataModel.Response.BaseResponse UpdateAlbum(DataModel.Model.AlbumModel album)
 {
     try
     {
         IAlbumRepository albumRepository = RepositoryClassFactory.GetInstance().GetAlbumRepository();
         var _album = MapperUtil.CreateMapper().Mapper.Map <AlbumModel, Album>(album);
         albumRepository.Update(_album);
         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
         });
     }
 }
Ejemplo n.º 12
0
 public DataModel.Response.BaseResponse UpdateImportantDealine(DataModel.Model.ImportantDeadlineModel importantDeadline)
 {
     try
     {
         IImportantDeadlineRepository importantDeadlineRepository = RepositoryClassFactory.GetInstance().GetImportantDeadlineRepository();
         ImportantDeadline            _importantDeadline          = MapperUtil.CreateMapper().Mapper.Map <ImportantDeadlineModel, ImportantDeadline>(importantDeadline);
         importantDeadlineRepository.Update(_importantDeadline);
         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
         });
     }
 }
Ejemplo n.º 13
0
 public DataModel.Response.BaseResponse Update(DataModel.Model.PaymentModel payment)
 {
     try
     {
         IPaymentRepository paymentRepository = RepositoryClassFactory.GetInstance().GetPaymentRepository();
         var _payment = MapperUtil.CreateMapper().Mapper.Map <PaymentModel, Payment>(payment);
         paymentRepository.Update(_payment);
         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
         });
     }
 }
Ejemplo n.º 14
0
 public DataModel.Response.BaseResponse Update(DataModel.Model.ExperienceModel experience)
 {
     try
     {
         IExperienceRepository experienceRepository = RepositoryClassFactory.GetInstance().GetExperienceRepository();
         var _experience = MapperUtil.CreateMapper().Mapper.Map <ExperienceModel, Experience>(experience);
         experienceRepository.Update(_experience);
         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
         });
     }
 }
Ejemplo n.º 15
0
 public BaseResponse Update(EducationModel education)
 {
     try
     {
         IEducationRepository educationRepository = RepositoryClassFactory.GetInstance().GetEducationRepository();
         var _education = MapperUtil.CreateMapper().Mapper.Map <EducationModel, Education>(education);
         educationRepository.Update(_education);
         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
         });
     }
 }
Ejemplo n.º 16
0
 public BaseResponse UpdateNews(NewsModel news)
 {
     try
     {
         INewsRepository newsRepository = RepositoryClassFactory.GetInstance().GetNewsRepository();
         News            _news          = MapperUtil.CreateMapper().Mapper.Map <NewsModel, News>(news);
         newsRepository.Update(_news);
         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
         });
     }
 }
Ejemplo n.º 17
0
 public DataModel.Response.InsertResponse Create(DataModel.Model.SessionModel session)
 {
     try
     {
         ISessionRepository sessionRepository = RepositoryClassFactory.GetInstance().GetSessionRepository();
         object             id = sessionRepository.Insert(MapperUtil.CreateMapper().Mapper.Map <SessionModel, Session>(session));
         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
         });
     }
 }
Ejemplo n.º 18
0
 public DataModel.Response.BaseResponse UpdateUpload(DataModel.Model.UploadModel upload)
 {
     try
     {
         IUploadRepository uploadRepository = RepositoryClassFactory.GetInstance().GetUploadRepository();
         Upload            _upload          = MapperUtil.CreateMapper().Mapper.Map <UploadModel, Upload>(upload);
         uploadRepository.Update(_upload);
         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
         });
     }
 }
Ejemplo n.º 19
0
 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.BaseResponse Update(DataModel.Model.MainScholarshipModel scholarship)
 {
     try
     {
         IMainScholarshipRepository mainScholarshipRepository = RepositoryClassFactory.GetInstance().GetMainScholarshipRepository();
         var _scholarship = MapperUtil.CreateMapper().Mapper.Map <MainScholarshipModel, MainScholarship>(scholarship);
         mainScholarshipRepository.Update(_scholarship);
         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
         });
     }
 }
Ejemplo n.º 21
0
 public DataModel.Response.BaseResponse UpdatePresentation(DataModel.Model.PresentationModel presentation)
 {
     try
     {
         IPresentationRepository preRepository = RepositoryClassFactory.GetInstance().GetPresentationRepository();
         var _pre = MapperUtil.CreateMapper().Mapper.Map <PresentationModel, Presentation>(presentation);
         preRepository.Update(_pre);
         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
         });
     }
 }
Ejemplo n.º 22
0
 public DataModel.Response.BaseResponse Update(DataModel.Model.LogisticScheduleModel logistic)
 {
     try
     {
         ILogisticSheduleRepository logisticRepository = RepositoryClassFactory.GetInstance().GetLogisticRepository();
         LogisticSchedule           _logistic          = MapperUtil.CreateMapper().Mapper.Map <LogisticScheduleModel, LogisticSchedule>(logistic);
         logisticRepository.Update(_logistic);
         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
         });
     }
 }
Ejemplo n.º 23
0
 public DataModel.Response.BaseResponse Update(DataModel.Model.TrainingModel training)
 {
     try
     {
         ITrainingRepository trainingRepository = RepositoryClassFactory.GetInstance().GetTrainingRepository();
         var _training = MapperUtil.CreateMapper().Mapper.Map <TrainingModel, Training>(training);
         trainingRepository.Update(_training);
         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
         });
     }
 }
Ejemplo n.º 24
0
 public BaseResponse UpdateSubscriber(SubscriberModel subscriber)
 {
     try
     {
         ISubscriberRepository subscriberRepository = RepositoryClassFactory.GetInstance().GetSubscriberRepository();
         var _sub = MapperUtil.CreateMapper().Mapper.Map <SubscriberModel, Subscriber>(subscriber);
         subscriberRepository.Update(_sub);
         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
         });
     }
 }
Ejemplo n.º 25
0
 public DataModel.Response.BaseResponse UpdateConference(DataModel.Model.ConferenceDeclarationModel conference)
 {
     try
     {
         IConferenceDeclarationRepository conferenceRepository = RepositoryClassFactory.GetInstance().GetConferenceDeclarationRepository();
         var _con = MapperUtil.CreateMapper().Mapper.Map <ConferenceDeclarationModel, ConferenceDeclaration>(conference);
         conferenceRepository.Update(_con);
         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
         });
     }
 }
Ejemplo n.º 26
0
 public BaseResponse UpdateMenu(MenuModel menu)
 {
     try
     {
         IMenuRepository menuRepository = RepositoryClassFactory.GetInstance().GetMenuRepository();
         Menu            _menu          = MapperUtil.CreateMapper().Mapper.Map <MenuModel, Menu>(menu);
         menuRepository.Update(_menu);
         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
         });
     }
 }
Ejemplo n.º 27
0
 public DataModel.Response.InsertResponse Create(DataModel.Model.LogisticScheduleModel logistic)
 {
     try
     {
         ILogisticSheduleRepository logisticRepository = RepositoryClassFactory.GetInstance().GetLogisticRepository();
         object id = logisticRepository.Insert(MapperUtil.CreateMapper().Mapper.Map <LogisticScheduleModel, LogisticSchedule>(logistic));
         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
         });
     }
 }
Ejemplo n.º 28
0
 public DataModel.Response.BaseResponse UpdateMailingAddress(DataModel.Model.MailingAddressModel mailing)
 {
     try
     {
         IMailingAddressRepository mailingRepository = RepositoryClassFactory.GetInstance().GetMailingAddressRepository();
         MailingAddress            _mailing          = MapperUtil.CreateMapper().Mapper.Map <MailingAddressModel, MailingAddress>(mailing);
         mailingRepository.Update(_mailing);
         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
         });
     }
 }
Ejemplo n.º 29
0
 public DataModel.Response.BaseResponse UpdateVideo(DataModel.Model.VideoModel video)
 {
     try
     {
         IVideoRepository videoRepository = RepositoryClassFactory.GetInstance().GetVideoRepository();
         var _video = MapperUtil.CreateMapper().Mapper.Map <VideoModel, Video>(video);
         videoRepository.Update(_video);
         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
         });
     }
 }
Ejemplo n.º 30
0
 public FindItemReponse <MenuModel> FindByID(string id)
 {
     try
     {
         IMenuRepository menuRepository = RepositoryClassFactory.GetInstance().GetMenuRepository();
         Menu            _menu          = menuRepository.FindByID(id);
         return(new FindItemReponse <MenuModel>
         {
             Item = MapperUtil.CreateMapper().Mapper.Map <Menu, MenuModel>(_menu),
             ErrorCode = (int)ErrorCode.None,
             Message = Resources.Resource.msg_create_success
         });
     }
     catch (Exception ex)
     {
         return(new FindItemReponse <MenuModel>
         {
             ErrorCode = (int)ErrorCode.Error,
             Message = ex.Message
         });
     }
 }