コード例 #1
0
        public async Task <bool> DeleteAsync(IChoiceModel choice)
        {
            var _choice = await _context.Choices.FindAsync(choice.ChoiceID);

            _context.Choices.Remove(_choice);
            return(true);
        }
コード例 #2
0
        public async Task <IChoiceModel> UpdateAsync(IChoiceModel choice)
        {
            var _choice = await _context.Choices.FindAsync(choice.ChoiceID);

            _context.Entry(_choice).CurrentValues.SetValues(_mapper.Map <IChoiceModel, Choice>(choice));
            return(choice);
        }
コード例 #3
0
        public async Task <IChoiceModel> LoadAlternativesPageAsync(IChoiceModel choice, int PageNumber, int PageSize = 5)
        {
            var _choice = await _context.Choices.FindAsync(choice.ChoiceID);

            await _context.Entry(_choice).Collection(c => c.Alternatives).Query().OrderBy(x => x.DateCreated).Skip((PageNumber - 1) * PageSize).Take(PageSize).LoadAsync();

            return(_mapper.Map <Choice, IChoiceModel>(_choice));;
        }
コード例 #4
0
ファイル: ChoiceService.cs プロジェクト: lbuday/Internship
        public async Task <bool> DeleteAsync(IChoiceModel choice)
        {
            bool b = true;

            b = await _choiceRepository.DeleteAsync(choice);

            await _choiceRepository.SaveAsync();

            return(b);
        }
コード例 #5
0
ファイル: ChoiceService.cs プロジェクト: lbuday/Internship
        public async Task <IChoiceModel> CreateAsync(IChoiceModel choice)
        {
            choice.ChoiceID    = Guid.NewGuid();
            choice.DateCreated = DateTime.Now;
            choice.DateUpdated = DateTime.Now;

            _choiceRepository.Add(choice);
            await _choiceRepository.SaveAsync();


            return(choice);
        }
コード例 #6
0
ファイル: ChoiceModelSession.cs プロジェクト: sdrewc/DaySim
        public TChoiceModel Get<TChoiceModel>() where TChoiceModel : IChoiceModel {
            Type requestedType = typeof(TChoiceModel);
            IChoiceModel choiceModelObject = choiceModelObjectsDictionary.GetOrAdd(requestedType, (key) => {
                //create the Singleton of type (or derived type) of TChoiceModel
                Type possiblyCustomizedType = Global.Configuration.getAssignableObjectType(requestedType);
                choiceModelObject = (IChoiceModel)Activator.CreateInstance(possiblyCustomizedType);

                choiceModelObject.RunInitialize();
                Global.PrintFile.WriteLine("CustomizationDll Get<TChoiceModel> for '" + requestedType + "' just created object of type '" + possiblyCustomizedType);
                return choiceModelObject;
            });

            return (TChoiceModel)choiceModelObject;
        }   //end Get<TChoiceModel>
コード例 #7
0
ファイル: ChoiceService.cs プロジェクト: lbuday/Internship
        public async Task <IChoiceModel> UpdateAsync(IChoiceModel choice)
        {
            IChoiceModel updated;
            var          _baseChoice = await _choiceRepository.GetByIDAsync(choice.ChoiceID);

            if (choice.ChoiceName != null)
            {
                _baseChoice.ChoiceName = choice.ChoiceName;
            }
            _baseChoice.DateUpdated = DateTime.Now;

            updated = await _choiceRepository.UpdateAsync(_baseChoice);

            await _choiceRepository.SaveAsync();

            return(updated);
        }
コード例 #8
0
 public IChoiceModel Add(IChoiceModel choice)
 {
     _context.Choices.Add(_mapper.Map <IChoiceModel, Choice>(choice));
     return(choice);
 }