public async Task <bool> DeleteAsync(IChoiceModel choice) { var _choice = await _context.Choices.FindAsync(choice.ChoiceID); _context.Choices.Remove(_choice); return(true); }
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); }
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));; }
public async Task <bool> DeleteAsync(IChoiceModel choice) { bool b = true; b = await _choiceRepository.DeleteAsync(choice); await _choiceRepository.SaveAsync(); return(b); }
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); }
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>
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); }
public IChoiceModel Add(IChoiceModel choice) { _context.Choices.Add(_mapper.Map <IChoiceModel, Choice>(choice)); return(choice); }