Esempio n. 1
0
        public List <Visit> GetVisitByID(int clientID)
        {
            var query = new List <Visit>();

            using (var context = new VisitsDatabaseEntities())
            {
                query = context.Visits.Where(x => x.ClientID == clientID).ToList();
            }

            return(query);
        }
Esempio n. 2
0
        public Client GetClientByDocument(string documento, int docType)
        {
            var query = new Client();

            using (var context = new VisitsDatabaseEntities())
            {
                query = (from c in context.Clients
                         where c.Document == documento && c.DocumentType == docType
                         select c).FirstOrDefault();
            }

            return(query);
        }
Esempio n. 3
0
        public List <DocumentType> GetDocumentTypes()
        {
            var query = new List <DocumentType>();

            using (var context = new VisitsDatabaseEntities())
            {
                query = (from dt in context.DocumentTypes
                         orderby dt.DocumentTypeID ascending
                         select dt).ToList();
            }

            return(query);
        }
Esempio n. 4
0
        public Seller GetSellerByDocument(string documento, int docType)
        {
            var query = new Seller();

            using (var context = new VisitsDatabaseEntities())
            {
                query = (from s in context.Sellers
                         where s.Document == documento && s.DocumentType == docType
                         select s).FirstOrDefault();
            }

            return(query);
        }
Esempio n. 5
0
        public List <Seller> GetSellers()
        {
            var query = new List <Seller>();

            using (var context = new VisitsDatabaseEntities())
            {
                context.Database.Connection.Open();
                query = (from s in context.Sellers
                         orderby s.SellerName ascending
                         select s).ToList();
            }

            return(query);
        }
Esempio n. 6
0
        public Client SaveClient(Client client)
        {
            var cl = new Client();

            using (var context = new VisitsDatabaseEntities())
            {
                var cc = context.Clients.FirstOrDefault(x => x.Document == client.Document && x.DocumentType == client.DocumentType);

                if (cc == null)
                {
                    var c = new Client();
                    c              = new Client();
                    c.Document     = client.Document;
                    c.DocumentType = client.DocumentType;
                    c.ClientName   = client.ClientName;
                    c.ContactName  = client.ContactName;
                    c.Email        = client.Email;
                    c.Phone        = client.Phone;
                    c.Address      = client.Address;
                    c.Position     = client.Position;
                    c.Consumption  = client.Consumption;
                    c.Fabric       = client.Fabric;

                    context.Clients.Add(c);

                    context.SaveChanges();

                    cl = c;
                }
                else
                {
                    cc.ClientName  = client.ClientName;
                    cc.ContactName = client.ContactName;
                    cc.Email       = client.Email;
                    cc.Phone       = client.Phone;
                    cc.Address     = client.Address;
                    cc.Position    = client.Position;
                    cc.Consumption = client.Consumption;
                    cc.Fabric      = client.Fabric;

                    context.SaveChanges();

                    cl = cc;
                }
            }

            return(cl);
        }
Esempio n. 7
0
        public int SaveVisit(Visit saveVisit)
        {
            int id = 0;

            using (var context = new VisitsDatabaseEntities())
            {
                var visit = new Visit();

                visit              = new Visit();
                visit.ClientID     = saveVisit.ClientID;
                visit.SellerID     = saveVisit.SellerID;
                visit.Observations = saveVisit.Observations;
                visit.VistDate     = saveVisit.VistDate;

                context.Visits.Add(visit);
                context.SaveChanges();

                id = visit.VisitsID;
            }
            return(id);
        }