Exemple #1
0
        private bool TryAskingIfExists(IBlueprint asked)
        {
            bool exists;
            BlueprintAndEntityConverter translator = new BlueprintAndEntityConverter();
            BlueprintEntity             toAsk      = translator.BlueprintToEntiy(asked);

            using (BlueBuilderDBContext context = new BlueBuilderDBContext())
            {
                Guid askedId = asked.GetId();
                exists = context.Blueprints.Any(bp => bp.Id == askedId);
            }
            return(exists);
        }
Exemple #2
0
        private void TryToDelete(IBlueprint toRemove)
        {
            if (Exists(toRemove))
            {
                BlueprintAndEntityConverter translator = new BlueprintAndEntityConverter();
                BlueprintEntity             converted  = translator.BlueprintToEntiy(toRemove);

                using (BlueBuilderDBContext context = new BlueBuilderDBContext())
                {
                    Guid            removeId = toRemove.GetId();
                    BlueprintEntity record   = context.Blueprints.FirstOrDefault(be => be.Id == removeId);
                    context.Blueprints.Remove(record);
                    context.SaveChanges();
                }
            }
        }
Exemple #3
0
        public void Add(IBlueprint toStore)
        {
            BlueprintAndEntityConverter   blueprintTranslator = new BlueprintAndEntityConverter();
            MaterialAndEntityConverter    materialTranslator  = new MaterialAndEntityConverter();
            BlueprintEntity               converted           = blueprintTranslator.BlueprintToEntiy(toStore);
            IEnumerable <ColumnEntity>    convertedColumns    = toStore.GetColumns().Select(c => materialTranslator.ColumnToEntity((Column)c, converted));
            IEnumerable <WallEntity>      convertedWalls      = toStore.GetWalls().Select(w => materialTranslator.WallToEntity(w, converted));
            IEnumerable <SignatureEntity> convertedSignatures = toStore.GetSignatures().Select(s => blueprintTranslator.SignatureToEntity(s, converted));
            ICollection <Opening>         itsOpenings         = toStore.GetOpenings();

            try
            {
                AddBlueprintEntity(converted, convertedWalls, convertedColumns, itsOpenings, convertedSignatures);
            }
            catch (DbException) {
                throw new InaccessibleDataException();
            }
        }