Esempio n. 1
0
 protected decimal?TryParseNullableDecimal(Cell cell, IXlsxImportResult xlsxImportResult)
 {
     if (string.IsNullOrEmpty(cell.Value))
     {
         return(null);
     }
     return(TryParseDecimal(cell, xlsxImportResult));
 }
Esempio n. 2
0
        protected TEnum TryParseEnum <TEnum>(Cell cell, IXlsxImportResult xlsxImportResult) where TEnum : struct
        {
            if (!LocalizationService.IsEnumExistsForLocalisedText <TEnum>(cell.Value))
            {
                xlsxImportResult.ErrorList.Add(string.Format(LocalizationService.GetLocalizedError(ValidationError.WrongDataFormat), cell.Id));
                return(default(TEnum));
            }

            return(LocalizationService.GetEnumFromLocalizedText <TEnum>(cell.Value));
        }
Esempio n. 3
0
        protected DateTime TryParseDateTime(Cell cell, IXlsxImportResult xlsxImportResult)
        {
            DateTime result;

            if (!DateTime.TryParse(cell.Value, out result))
            {
                xlsxImportResult.ErrorList.Add(string.Format(LocalizationService.GetLocalizedError(ValidationError.WrongDataFormat), cell.Id));
            }

            return(result);
        }
        protected Guid TryGetBelastungskategorie(Cell cell, IXlsxImportResult xlsxImportResult)
        {
            var belastungskategorie = belastungskategorieService
                                      .AllBelastungskategorieModel
                                      .SingleOrDefault(bkm => LocalizationService.GetLocalizedBelastungskategorieTyp(bkm.Typ) == cell.Value);

            if (belastungskategorie == null)
            {
                xlsxImportResult.ErrorList.Add(string.Format(LocalizationService.GetLocalizedError(ValidationError.WrongDataFormat), cell.Id));
                return(Guid.Empty);
            }

            return(belastungskategorie.Id);
        }
Esempio n. 5
0
        protected int?TryParseNullableInt(Cell cell, IXlsxImportResult xlsxImportResult)
        {
            if (string.IsNullOrEmpty(cell.Value))
            {
                return(null);
            }

            int result;

            if (!int.TryParse(cell.Value, out result))
            {
                xlsxImportResult.ErrorList.Add(string.Format(LocalizationService.GetLocalizedError(ValidationError.WrongDataFormat), cell.Id));
            }

            return(result);
        }
Esempio n. 6
0
        protected Guid?TryGetMassnahmenvorschlagKatalog(Cell cell, MassnahmenvorschlagKatalogTyp massnahmenvorschlagKatalogTyp, string belastungskategorieTyp, IXlsxImportResult xlsxImportResult)
        {
            if (string.IsNullOrEmpty(cell.Value))
            {
                return(null);
            }

            var massnahmenvorschlagKatalogModel = massnahmenvorschlagKatalogService
                                                  .GetMassnahmenvorschlagKatalogModelList(massnahmenvorschlagKatalogTyp, belastungskategorieTyp)
                                                  .SingleOrDefault(mkm => mkm.TypBezeichnung == cell.Value);

            if (massnahmenvorschlagKatalogModel == null)
            {
                xlsxImportResult.ErrorList.Add(string.Format(LocalizationService.GetLocalizedError(ValidationError.WrongDataFormat), cell.Id));
                return(Guid.Empty);
            }

            return(massnahmenvorschlagKatalogModel.Id);
        }