Ejemplo n.º 1
0
        public async Task <Charge> SetDefaultValuesAsync(Battery battery, Charge charge)
        {
            charge.BatteryId = battery.Id;
            charge.OwnerId   = battery.OwnerId;


            var initialStatus = await _statusService.GetInitialStatusAsync(charge.BatteryId);

            charge.StatusId = initialStatus.Id;

            var category = await _categoryService.GetDefaultChargeCategoryAsync(battery.Id);

            charge.CategoryId = category.Id;

            var defaultPriority = await _priorityService.GetDefaultAsync(battery.Id);

            charge.PriorityId = defaultPriority.Id;

            return(charge);
        }
        public async Task <Charge> SetRelationshipAsync(Charge parent, Charge child)
        {
            // Set child charge fields from parent charge
            child.ParentId  = parent.Id;
            child.OwnerId   = parent.OwnerId;
            child.BatteryId = parent.BatteryId;
            // Get Child category ("spark") and assign it to child
            var childCategory = await _categoryService.GetDefaultChildCategoryAsync(parent.BatteryId);

            child.CategoryId = childCategory.Id;
            // Set child priority to default priority
            var defaultPriority = await _priorityService.GetDefaultAsync(parent.BatteryId);

            child.PriorityId = defaultPriority.Id;
            // Set child to initial status
            var initialStatus = await _statusService.GetInitialStatusAsync(parent.BatteryId);

            child.StatusId = initialStatus.Id;

            return(child);
        }