예제 #1
0
        void ReloadData()
        {
            var dataSource = _dataSourceFactory.GetDataSource();

            ProfitData = new JellyBeanProfitCalculator(dataSource).CalculateProfit();
            if (DataLoaded != null)
            {
                DataLoaded();
            }
        }
예제 #2
0
        public virtual async Task <ItemResult> ChangeSpacesToDashesInName([FromServices] IDataSourceFactory dataSourceFactory, int id)
        {
            var dataSource = dataSourceFactory.GetDataSource <Coalesce.Domain.Person, Coalesce.Domain.Person>("WithoutCases");

            var(itemResult, _) = await dataSource.GetItemAsync(id, new ListParameters());

            if (!itemResult.WasSuccessful)
            {
                return(new ItemResult(itemResult));
            }
            var item         = itemResult.Object;
            var methodResult = item.ChangeSpacesToDashesInName();
            await Db.SaveChangesAsync();

            var result = new ItemResult(methodResult);

            return(result);
        }
예제 #3
0
        public virtual async Task <ItemResult <string> > ObfuscateEmail([FromServices] IDataSourceFactory dataSourceFactory, int id)
        {
            var dataSource = dataSourceFactory.GetDataSource <Coalesce.Domain.Person, Coalesce.Domain.Person>("Default");

            var(itemResult, _) = await dataSource.GetItemAsync(id, new ListParameters());

            if (!itemResult.WasSuccessful)
            {
                return(new ItemResult <string>(itemResult));
            }
            var item         = itemResult.Object;
            var methodResult = item.ObfuscateEmail(Db);
            await Db.SaveChangesAsync();

            var result = new ItemResult <string>();

            result.Object = methodResult;
            return(result);
        }
예제 #4
0
        public virtual async Task <ItemResult <string> > AsyncMethodOnIClassDto([FromServices] IDataSourceFactory dataSourceFactory, int id, string input)
        {
            var dataSource = dataSourceFactory.GetDataSource <Coalesce.Domain.Case, Coalesce.Domain.CaseDto>("Default");
            var itemResult = await dataSource.GetMappedItemAsync <Coalesce.Domain.CaseDto>(id, new ListParameters());

            if (!itemResult.WasSuccessful)
            {
                return(new ItemResult <string>(itemResult));
            }
            var item         = itemResult.Object;
            var methodResult = await item.AsyncMethodOnIClassDto(input);

            await Db.SaveChangesAsync();

            var result = new ItemResult <string>();

            result.Object = methodResult;
            return(result);
        }
예제 #5
0
        public virtual async Task <ItemResult> SaveWithDelay([FromServices] IDataSourceFactory dataSourceFactory, int id)
        {
            var dataSource = dataSourceFactory.GetDataSource <CoalescePlayground.Data.Models.Person, CoalescePlayground.Data.Models.Person>("Default");

            var(itemResult, _) = await dataSource.GetItemAsync(id, new ListParameters());

            if (!itemResult.WasSuccessful)
            {
                return(new ItemResult(itemResult));
            }
            var item = itemResult.Object;

            item.SaveWithDelay(Db);
            await Db.SaveChangesAsync();

            var result = new ItemResult();

            return(result);
        }
예제 #6
0
        public virtual async Task <ItemResult <PersonDtoGen> > ChangeFirstName([FromServices] IDataSourceFactory dataSourceFactory, int id, string firstName)
        {
            IncludeTree includeTree = null;
            var         dataSource  = dataSourceFactory.GetDataSource <Coalesce.Domain.Person, Coalesce.Domain.Person>("Default");

            var(itemResult, _) = await dataSource.GetItemAsync(id, new ListParameters());

            if (!itemResult.WasSuccessful)
            {
                return(new ItemResult <PersonDtoGen>(itemResult));
            }
            var item         = itemResult.Object;
            var methodResult = item.ChangeFirstName(firstName);
            await Db.SaveChangesAsync();

            var result         = new ItemResult <PersonDtoGen>();
            var mappingContext = new MappingContext(User, "");

            result.Object = Mapper.MapToDto <Coalesce.Domain.Person, PersonDtoGen>(methodResult, mappingContext, includeTree);
            return(result);
        }
예제 #7
0
 public void Init(object initData)
 {
     GraphData = new JellyBeanGraphCalculator(_dataSourceFactory.GetDataSource()).GetGraphData();
 }
예제 #8
0
 public void Init(object initData)
 {
     JellyBeanValues = new ObservableCollection <Object>(_dataSourceFactory.GetDataSource().GetJellyBeanValues().Result);
 }