Ejemplo n.º 1
0
 public override DTOProdotto GetByID(GuidKey chiave)
 {
     using (var ctx = new EntityModel.SqlServerEntities())
     {
         return(MapTable(ctx.tabProdotti.FirstOrDefault(x => x.ID.Equals(chiave.ID))));
     }
 }
Ejemplo n.º 2
0
        protected override GuidKey InnerUpdateOrInsert(DTOProdotto Dato)
        {
            using (var ctx = new EntityModel.SqlServerEntities())
            {
                var tab = new tabProdotti();
                if (!ctx.tabProdotti.Any(x => x.ID.Equals(Dato.ID)))
                {
                    Dato.ID = new Guid();
                    ctx.Entry(tab).State = EntityState.Added;
                }
                else
                {
                    ctx.Entry(tab).State = EntityState.Modified;
                }
                tab.Descrizione      = Dato.Descrizione;
                tab.DescrizioneBreve = Dato.DescrizioneBreve;
                tab.isDeleted        = false;
                tab.ID = Dato.ID;

                if (Dato.ProdottiDiListino != null)
                {
                }

                ctx.SaveChanges();
                return(Dato.Identifier);
            }
        }
Ejemplo n.º 3
0
        protected override bool InnerDelete(GuidKey Chiave)
        {
            if (Chiave == null)
            {
                return(false);
            }
            using (var ctx = new EntityModel.SqlServerEntities())
            {
                if (!ctx.tabProdotti.Any(x => x.ID.Equals(Chiave.ID)))
                {
                    return(false);
                }

                var dto = ctx.tabProdotti.FirstOrDefault(x => x.ID.Equals(Chiave.ID) && !x.isDeleted);
                //ctx.tabProdotti.Remove(dto);
                if (dto == null)
                {
                    return(false);
                }
                dto.isDeleted = true;
                ctx.SaveChanges();
                return(true);
            }
        }
Ejemplo n.º 4
0
 protected BaseService(Guid identifier, EntityModel.SqlServerEntities context)
 {
     _myIdentifier = identifier;
     _context      = context;
 }