Esempio n. 1
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);
        }
Esempio n. 2
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;
                }
            }
        }
Esempio n. 3
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);
        }