예제 #1
0
        public string FindUserByEmail(string Email)
        {
            string password = "";

            IQueryable <User> lista = null;

            using (var context = new AgileInvoiceDbContext(connString))
            {
                lista = from item in context.Users
                        where item.Email == Email
                        select item;

                if (lista.Count() > 0)
                {
                    password = lista.FirstOrDefault().Password;
                }
            }

            //IQueryable algo = null;
            //using (var context = new AgileInvoiceDbContext(connString))
            //{
            //     algo = context.Users
            //                .Where(w => w.Email == Email)
            //                .Select(s => s.Password);

            //}

            return(password);
        }
예제 #2
0
        public TaxProfileType FindTaxProfileByIdentification(string Identification)
        {
            TaxProfileType item = null;

            using (var context = new AgileInvoiceDbContext(_connectionString))
            {
                IQueryable <TaxProfile> lista = from row in context.TaxProfiles
                                                where row.Identification == Identification
                                                select row;
                if (lista.Count() > 0)
                {
                    var entitie = lista.FirstOrDefault();
                    item.IdTaxProfile   = entitie.IdTaxProfile;
                    item.Name           = entitie.Name;
                    item.Identification = entitie.Identification;
                    item.Street         = entitie.Street;
                    item.ExteriorNumber = entitie.ExteriorNumber;
                    item.InteriorNumber = entitie.InteriorNumber;
                    item.Suburb         = entitie.Suburb;
                    item.Municipality   = entitie.Municipality;
                    item.State          = entitie.State;
                    item.Country        = entitie.Country;
                    item.PostCode       = entitie.PostCode;
                }
            }
            return(item);
        }
예제 #3
0
        public IEnumerable <TaxProfileType> FindAllTaxProfiles()
        {
            IEnumerable <TaxProfileType> lista = null;

            //IQueryable<TaxProfile> lista = null; //NOTA: no se utiliza el IQueryable porque estamos convirtiendo a  TaxProfileType y no TaxProfile como es por default.
            using (var context = new AgileInvoiceDbContext(_connectionString))
            {
                lista = from row in context.TaxProfiles
                        select new TaxProfileType
                {
                    IdTaxProfile   = row.IdTaxProfile,
                    Name           = row.Name,
                    Identification = row.Identification,
                    Street         = row.Street,
                    ExteriorNumber = row.ExteriorNumber,
                    InteriorNumber = row.InteriorNumber,
                    Suburb         = row.Suburb,
                    Municipality   = row.Municipality,
                    State          = row.State,
                    Country        = row.Country,
                    PostCode       = row.PostCode
                };
                lista = lista.ToList();// sino se hace .ToList() marca un Error: "The operation cannot be completed because the DbContext has been disposed."
            }
            return(lista);
        }
예제 #4
0
        public int UpdateTaxProfile(TaxProfileType item)
        {
            int result = 0;

            using (var context = new AgileInvoiceDbContext(_connectionString))
            {
                IQueryable <TaxProfile> lista = from row in context.TaxProfiles
                                                where row.IdTaxProfile == item.IdTaxProfile
                                                select row;
                if (lista.Count() > 0)
                {
                    var entitie = lista.FirstOrDefault();

                    entitie.Name             = item.Name;
                    entitie.Identification   = item.Identification;
                    entitie.Street           = item.Street;
                    entitie.ExteriorNumber   = item.ExteriorNumber;
                    entitie.InteriorNumber   = item.InteriorNumber;
                    entitie.Suburb           = item.Suburb;
                    entitie.Municipality     = item.Municipality;
                    entitie.State            = item.State;
                    entitie.Country          = item.Country;
                    entitie.PostCode         = item.PostCode;
                    entitie.ModificationDate = DateTime.Now;

                    result = context.SaveChanges();
                }
            }
            return(result);
        }
예제 #5
0
        public IEnumerable <InvoiceRequestType> FindAllInvoiceRequest()
        {
            List <InvoiceRequestType> result = null;

            using (var context = new AgileInvoiceDbContext(_stringconn))
            {
                IQueryable <InvoiceRequest> lista = null;
                lista = from row in context.InvoiceRequests
                        select row;
                if (lista.Count() > 0)
                {
                    result = new List <InvoiceRequestType>();
                    InvoiceRequestType item = null;
                    foreach (var row in lista)
                    {
                        item             = new InvoiceRequestType();
                        item.IdSender    = row.IdSender;
                        item.FolioNumber = row.FolioNumber;
                        item.IdUser      = row.IdUser;
                        result.Add(item);
                    }
                }
            }

            return(result);
        }
예제 #6
0
        public bool IsEmailRegistered(string Email)
        {
            bool result = false;

            using (var context = new AgileInvoiceDbContext(connString))
            {
                //result = context.Users.Select(item => item.Email == Email).FirstOrDefault();
                IQueryable <User> lista = from row in context.Users
                                          where row.Email == Email
                                          select row;
                if (lista.Count() > 0)
                {
                    return(true);
                }
            }
            return(result);
        }
예제 #7
0
        public int AddUser(UserSignUp entitie)
        {
            int result = 0;

            using (var context = new AgileInvoiceDbContext(connString))
            {
                User item = new User();
                item.Name         = entitie.Name;
                item.Email        = entitie.Email;
                item.Password     = entitie.Password;
                item.CreationDate = DateTime.Now;

                context.Users.Add(item);
                result = context.SaveChanges();
            }
            return(result);
        }
예제 #8
0
        public int RemoveTaxProfile(int Id)
        {
            int result = 0;

            using (var context = new AgileInvoiceDbContext(_connectionString))
            {
                //IQueryable<TaxProfile> lista = context.TaxProfiles.Select(item => item.Identification == Identification).ToList();
                IQueryable <TaxProfile> lista = from row in context.TaxProfiles
                                                where row.IdTaxProfile == Id
                                                select row;
                if (lista.Count() > 0)
                {
                    context.TaxProfiles.Remove(lista.FirstOrDefault());
                    result = context.SaveChanges();
                }
            }
            return(result);
        }
예제 #9
0
        public bool FindUserByEmailAndPassword(UserSignIn entitie)
        {
            bool result = false;

            IQueryable <User> lista = null;

            using (var context = new AgileInvoiceDbContext(connString))
            {
                //result = context.Users.Select(item => item.Email == entitie.Email && item.Password == entitie.Password).FirstOrDefault(); //dejo de funcionar!!!
                lista = from item in context.Users
                        where item.Email == entitie.Email && item.Password == entitie.Password
                        select item;
                if (lista.Count() > 0)
                {
                    result = true;
                }
            }
            return(result);
        }
예제 #10
0
        public int AddTaxProfile(TaxProfileType item)
        {
            int result = 0;

            using (var context = new AgileInvoiceDbContext(_connectionString))
            {
                TaxProfile entitie = new TaxProfile();
                entitie.Name           = item.Name;
                entitie.Identification = item.Identification;
                entitie.Street         = item.Street;
                entitie.ExteriorNumber = item.ExteriorNumber;
                entitie.InteriorNumber = item.InteriorNumber;
                entitie.Suburb         = item.Suburb;
                entitie.Municipality   = item.Municipality;
                entitie.State          = item.State;
                entitie.Country        = item.Country;
                entitie.PostCode       = item.PostCode;
                entitie.CreationDate   = DateTime.Now;

                context.TaxProfiles.Add(entitie);
                result = context.SaveChanges();
            }
            return(result);
        }