Exemple #1
0
        public RawArticle Map(Record record)
        {
            if (record == null)
            {
                throw new ArgumentNullException(nameof(record));
            }

            RawArticle rawArticle = new RawArticle()
            {
                Ref                  = record.GetFieldAt(fieldMapping.Ref).ToUpper(),
                Libelle              = record.GetFieldAt(fieldMapping.Label),
                Localisation         = record.GetFieldAt(fieldMapping.Localisation),
                Quantite             = double.Parse(record.GetFieldAt(fieldMapping.Quantity)),
                IdMagasin            = int.Parse(record.GetFieldAt(fieldMapping.MagasinId)),
                LienFlu              = record.GetFieldAt(fieldMapping.Flu),
                InfosSupplementaires = record.GetFieldAt(fieldMapping.AdditionalInfos)
            };

            string epiLabel = record.GetFieldAt(fieldMapping.EpiLabel)?.Capitalize();

            if (epiLabel != null)
            {
                rawArticle.TypeEpi = new TypeEpi(epiLabel);
            }

            return(rawArticle);
        }
 private Article CreateArticleFromRawArticle(RawArticle rawArticle)
 {
     return(new Article(
                new ReferenceArticle(rawArticle.Ref),
                rawArticle.Libelle,
                rawArticle.Localisation,
                rawArticle.Quantite,
                rawArticle.InfosSupplementaires));
 }
        public Article Map(RawArticle rawArticle)
        {
            if (rawArticle == null)
            {
                throw new ArgumentNullException(nameof(rawArticle));
            }

            if (IsRawArticleBanalise(rawArticle))
            {
                return(rawArticle.IsEpi() ? CreateEpiFromRawArticle(rawArticle) :
                       CreateBanaliseFromRawArticle(rawArticle));
            }

            else if (IsRawArticleSEL(rawArticle))
            {
                return(CreateSelFromRawArticle(rawArticle));
            }
            else
            {
                throw new InvalidOperationException(nameof(rawArticle));
            }
        }
 private Sel CreateSelFromRawArticle(RawArticle rawArticle)
 {
     return(new Sel(
                CreateArticleFromRawArticle(rawArticle)));
 }
 private bool IsRawArticleSEL(RawArticle rawArticle)
 {
     return(rawArticle.IdMagasin == settings.IdMagasinSEL);
 }
 private Article CreateEpiFromRawArticle(RawArticle rawArticle)
 {
     return(new Epi(
                CreateBanaliseFromRawArticle(rawArticle),
                rawArticle.TypeEpi));
 }
 private Banalise CreateBanaliseFromRawArticle(RawArticle rawArticle)
 {
     return(new Banalise(
                CreateArticleFromRawArticle(rawArticle),
                rawArticle.LienFlu));
 }
 private bool IsRawArticleBanalise(RawArticle rawArticle)
 {
     return(rawArticle.IdMagasin == settings.IdMagasinBanalise);
 }