コード例 #1
0
        public async Task HandleValidSubmit(BatchTemplateViewModel model)
        {
            Console.WriteLine("OnValidSubmit");

            var sourceNumbers = await ApiNumberingService.GetSourceNextNumbers(Http, model.SourceCount);

            var materialNumbers = await ApiNumberingService.GetMaterialNextNumbers(Http, model.MaterialCount);

            var aliquotNumbers = await ApiNumberingService.GetAliquotNextNumbers(Http, model.AliquotCount);

            for (var sIndex = 0; sIndex < model.SourceCount; sIndex++)
            {
                var sourceTemplate = SourceTemplates.FirstOrDefault(s => s.Id == model.SourceTemplate.Id);
                for (var mIndex = 0; mIndex < model.MaterialCount; mIndex++)
                {
                    var materialTemplate = MaterialTemplates.FirstOrDefault(m => m.Id == model.MaterialTemplate.Id);
                    for (var aIndex = 0; aIndex < model.AliquotCount; aIndex++)
                    {
                        var aliquotTemplate = AliquotTemplates.FirstOrDefault(a => a.Id == model.AliquotTemplate.Id);
                        var dto             = new BatchRegistrationDto
                        {
                            SourceTemplate   = sourceTemplate,
                            MaterialTemplate = materialTemplate,
                            AliquotTemplate  = aliquotTemplate,
                            SourceBarcode    = sourceNumbers[sIndex],
                            MaterialBarcode  = materialNumbers[mIndex],
                            AliquotBarcode   = aliquotNumbers[aIndex],
                        };
                        DataSource.Add(dto);
                    }
                }
            }

            StateHasChanged();
        }
コード例 #2
0
        protected void OnRowUpdating(BatchRegistrationDto item, Dictionary <string, object> newValue)
        {
            if (item != null && newValue != null)
            {
                foreach (var field in newValue)
                {
                    Console.WriteLine(field.Key);
                    Console.WriteLine(field.Value);
                    switch (field.Key)
                    {
                    case nameof(BatchRegistrationDto.SourceTemplate):
                        if (field.Value is TemplateLookupItem sTemplate)
                        {
                            item.SourceTemplate = sTemplate;
                        }
                        break;

                    case nameof(BatchRegistrationDto.MaterialTemplate):
                        if (field.Value is TemplateLookupItem mTemplate)
                        {
                            item.SourceTemplate = mTemplate;
                        }
                        break;

                    case nameof(BatchRegistrationDto.AliquotTemplate):
                        if (field.Value is TemplateLookupItem aTemplate)
                        {
                            item.SourceTemplate = aTemplate;
                        }
                        break;

                    case nameof(BatchRegistrationDto.SourceBarcode):
                        if (field.Value is string sBarcode)
                        {
                            item.SourceBarcode = sBarcode;
                        }
                        break;

                    case nameof(BatchRegistrationDto.MaterialBarcode):
                        if (field.Value is string mBarcode)
                        {
                            item.MaterialBarcode = mBarcode;
                        }
                        break;

                    case nameof(BatchRegistrationDto.AliquotBarcode):
                        if (field.Value is string aBarcode)
                        {
                            item.AliquotBarcode = aBarcode;
                        }
                        break;

                    case nameof(BatchRegistrationDto.SourceTypeId):
                        if (field.Value is SourceMaterialTypeLookupItem sType)
                        {
                            item.SourceTypeId = sType.Id;
                            item.SourceType   = sType.Name;
                        }
                        break;

                    case nameof(BatchRegistrationDto.MaterialTypeId):
                        if (field.Value is SourceMaterialTypeLookupItem mType)
                        {
                            item.MaterialTypeId = mType.Id;
                            item.MaterialType   = mType.Name;
                        }
                        break;
                    }
                }
            }
        }