Ejemplo n.º 1
0
        protected async Task HandleSubmit()
        {
            if (RegionVMEditContext.Validate())
            {
                var districtData = await BudgetFrameService
                                   .GetAsync(x => x.RegionId == AdminRegionVM.RegionId &&
                                             x.Year == AdminRegionVM.Year);

                if (districtData != null)
                {
                    foreach (var item in AdminRegionVM.Services)
                    {
                        var budgetFrame = districtData.Where(x => x.ServiceTypeId == item.ServiceTypeId).FirstOrDefault();
                        budgetFrame.Head  = item.Head ?? 0;
                        budgetFrame.Value = item.Value ?? 0;
                        BudgetFrameService.Update(budgetFrame);
                        await BudgetFrameService
                        .SaveChangesAsync(AppUser.Instance.FullName);
                    }
                }
            }

            await InitializedAsync();

            ToggleView();

            await InvokeAsync(StateHasChanged);
        }
Ejemplo n.º 2
0
        protected async Task PeriodHandler(ChangeEventArgs args)
        {
            SelectedPeriod = Int32.Parse((string)args.Value);
            RegionFrameVMs = (await BudgetFrameService.GetRegionFrameVM(SelectedPeriod)).RegionFrameVMs;

            await InvokeAsync(StateHasChanged);
        }
Ejemplo n.º 3
0
        protected async Task DistrictEditClickHandler(MouseEventArgs e, int regionId)
        {
            ToggleView();

            AdminRegionVM = Mapper.Map <AdminRegionVM>(
                (await BudgetFrameService.GetRegionFrameVM(SelectedPeriod, regionId))
                .RegionFrameVMs.FirstOrDefault());
            AdminRegionVM.Year     = SelectedPeriod;
            AdminRegionVM.Services = Services.Select(x =>
                                                     new ServiceBase
            {
                ServiceTypeId   = x.ServiceTypeId,
                ServiceTypeName = x.ServiceType.Name,
                ServicePrice    = x.Price
            }).ToList();
            foreach (var item in AdminRegionVM.Services)
            {
                item.Head  = item.Head == 0 ? null : item.Head;
                item.Value = item.Value == 0 ? null : item.Value;
            }

            RegionVMEditContext = new EditContext(AdminRegionVM);

            await InvokeAsync(StateHasChanged);
        }
Ejemplo n.º 4
0
        protected async Task ProviderEventHandler(ChangeEventArgs args)
        {
            var existedBindings = (await ServiceDataService.GetAsync(x => 
            x.ContractNumber.Equals((string)args.Value)))
                .Select(x => x.RegionId)
                .Distinct()
                .ToList();
            var validFrames = await BudgetFrameService.GetAsync(x => 
            !existedBindings.Contains(x.RegionId) && x.Value > 0, 
            null, "Region,Service");

            AdminBindingVM.Regions = validFrames
                .Select(x => new
                {
                    x.RegionId,
                    x.Region.Name
                })
                .Distinct()
                .Select(x =>
                new DropDownData
                {
                    ValueInt = x.RegionId,
                    Text = x.Name
                })
                .ToList();

            BindingEditContext = new EditContext(AdminBindingVM);
            await InvokeAsync(StateHasChanged);
        }
Ejemplo n.º 5
0
        private async Task CalculateMaxValues(int regionId)
        {
            var budgetFrames = (await BudgetFrameService.GetAsync(x =>
                x.Year == AdminBindingVM.Year &&
                x.RegionId == regionId &&
                x.Head > 0,
                null,
                "Service"))
                .Select(x => new ServiceBase
                {
                    ServiceTypeId = x.ServiceTypeId,
                    ServiceTypeName = x.Service.ServiceType.Name,
                    ServicePrice = x.Service.Price,
                    ServiceDate = x.Service.ServiceTypeDate,
                    Head = x.Head,
                    Value = x.Value
                }).ToList();

            if (IsNew)
            {
                AdminBindingVM.Services = budgetFrames;
            }

            var services = await ServiceDataService.GetAsync(x =>
                x.RegionId == regionId &&
                x.Contract.Year == AdminBindingVM.Year
                );

            foreach (var item in AdminBindingVM.Services)
            {
                var serviceTypeData = services.Where(x => x.ServiceTypeId == item.ServiceTypeId).ToList();
                var budgetFramesServite = budgetFrames.Where(x => x.ServiceTypeId == item.ServiceTypeId).FirstOrDefault();

                item.MaxHead = (int)budgetFramesServite.Head - serviceTypeData.Sum(x => x.Head);
                item.MaxValue = (int)budgetFramesServite.Value - serviceTypeData.Sum(x => x.Value);

                if (IsNew)
                {
                    item.Head = 0;
                    item.Value = 0;
                }
            }
        }
Ejemplo n.º 6
0
        protected async Task HandleSubmit()
        {
            if (BindingEditContext.Validate())
            {
                foreach (var service in AdminBindingVM.Services)
                {
                    var binding = (await ServiceDataService.GetAsync(x =>
                       x.Contract.Year == AdminBindingVM.Year && 
                       x.ContractNumber.Equals(AdminBindingVM.ContractNumber) &&
                       x.RegionId == AdminBindingVM.RegionId &&
                       x.ServiceTypeId == service.ServiceTypeId &&
                       x.ServiceTypeDate.Equals(service.ServiceDate)))
                        .FirstOrDefault();

                    //új szerződés
                    if (binding == null)
                    {
                        await ServiceDataService.AddAsync(
                             new Data.ServiceData
                             {
                                 ContractNumber = AdminBindingVM.ContractNumber,
                                 RegionId = (int)AdminBindingVM.RegionId,
                                 ServiceTypeId = service.ServiceTypeId,
                                 ServiceTypeDate = service.ServiceDate,
                                 Head = (int)service.Head,
                                 Value = (int)service.Value
                             });
                    }
                    //Szerződésnmódosítás
                    else
                    {
                        binding.Head = (int)service.Head;
                        binding.Value = (int)service.Value;
                    }
                }
            }
            await ServiceDataService.SaveChangesAsync(AppUser.Instance.FullName);

            ProviderFrameByDistricts = await BudgetFrameService.GetProviderFrameByDistricts(SelectedPeriod);
            BindingEditContext = new EditContext(AdminBindingVM);
            ToggleView();
            await InvokeAsync(StateHasChanged);
        }
Ejemplo n.º 7
0
        private async Task InitializedAsync()
        {
            AdminRegionVM       = new AdminRegionVM();
            SelectedPeriod      = Int32.Parse(Period);
            RegionFrameVMs      = (await BudgetFrameService.GetRegionFrameVM(SelectedPeriod)).RegionFrameVMs;
            RegionVMEditContext = new EditContext(AdminRegionVM);
            Services            = await ServiceService.GetAsync(x =>
                                                                x.IsActive,
                                                                y => y.OrderBy(z => z.ServiceTypeId),
                                                                "ServiceType");

            Periods = (await PeriodService.GetAsync())
                      .Select(x => new DropDownData
            {
                Text     = x.Description,
                ValueInt = x.Year
            })
                      .OrderBy(x => x.ValueInt)
                      .ToList();
        }
Ejemplo n.º 8
0
 private async Task TableInitialiser()
 {
     ProviderFrameByDistricts = 
         await BudgetFrameService.GetProviderFrameByDistricts(SelectedPeriod);
 }