Example #1
0
        public UserMaster GetUserdetailsByUsernameAndRole(string name, string userRole)
        {
            UserMaster userMaster = new UserMaster();

            using (var context = new InvoiceGenEntities())
            {
                userMaster = (from a in context.UserMasters
                              where a.UserName == name
                              select a).FirstOrDefault();

                var userRoleMapping = (from a in context.UserRoleMappings
                                       where a.UserId == userMaster.ID
                                       select a).FirstOrDefault();


                var rolemaster = (from a in context.RoleMasters
                                  where a.ID == userRoleMapping.RoleId
                                  select a).FirstOrDefault();

                if (string.Equals(rolemaster.RoleName, userRole, StringComparison.InvariantCultureIgnoreCase))
                {
                    return(userMaster);
                }
                else
                {
                    return(null);
                }
            }
        }
Example #2
0
        public List <Operations> GetOperationListForUser(long userId)
        {
            List <Operations> opList = new List <Operations>();

            using (var context = new InvoiceGenEntities())
            {
                var userRoleMapping = (from a in context.UserRoleMappings
                                       where a.UserId == userId
                                       select a).FirstOrDefault();

                var rolemaster = (from a in context.RoleMasters
                                  where a.ID == userRoleMapping.RoleId
                                  select a).FirstOrDefault();
                List <RoleOperationMapping> roleOpMapping = new List <RoleOperationMapping>();
                roleOpMapping = (from a in context.RoleOperationMappings
                                 where a.RoleId == userRoleMapping.RoleId
                                 select a).ToList();
                foreach (RoleOperationMapping opMapp in roleOpMapping)
                {
                    Operations      op  = new Operations();
                    OperationMaster opm = new OperationMaster();
                    opm = (from a in context.OperationMasters
                           where a.ID == opMapp.OperationId
                           select a).FirstOrDefault();

                    if (opm != null)
                    {
                        op.OperationName = opm.OperationName;
                        opList.Add(op);
                    }
                }
            }
            return(opList);
        }
Example #3
0
 public long CreateNewProduct(ProductsMaster products)
 {
     using (var context = new InvoiceGenEntities())
     {
         context.ProductsMasters.Add(products);
         context.SaveChanges();//this generates the Id for customer
         return(products.ID);
     }
 }
Example #4
0
 public long SaveCustomerProductMapping(CustomerProductMapping customerProductMapping)
 {
     using (var context = new InvoiceGenEntities())
     {
         context.CustomerProductMappings.Add(customerProductMapping);
         context.SaveChanges();//this generates the Id for customer
         return(customerProductMapping.ID);
     }
 }
Example #5
0
 public long CreateNewCustomer(Customer customer)
 {
     using (var context = new InvoiceGenEntities())
     {
         context.Customers.Add(customer);
         context.SaveChanges();//this generates the Id for customer
         return(customer.ID);
     }
 }
Example #6
0
 public long CreateNewBill(BillMaster billMaster)
 {
     using (var context = new InvoiceGenEntities())
     {
         context.BillMasters.Add(billMaster);
         context.SaveChanges();//this generates the Id for customer
         return(billMaster.ID);
     }
 }
Example #7
0
        /// <summary>
        /// Returns List of all products
        /// </summary>
        /// <returns></returns>
        public List <ProductsMaster> GetAllProductList()
        {
            List <ProductsMaster> listProduct = new List <ProductsMaster>();

            using (var context = new InvoiceGenEntities())
            {
                listProduct = (from a in context.ProductsMasters
                               where a.Name != null
                               select a).ToList();
            }
            return(listProduct);
        }
Example #8
0
        public UserMaster GetUserdetailsByUsernamePass(string username, string passWord)
        {
            UserMaster userMaster = new UserMaster();

            using (var context = new InvoiceGenEntities())
            {
                userMaster = (from a in context.UserMasters
                              where a.UserName == username && a.password == passWord
                              select a).FirstOrDefault();
            }
            return(userMaster);
        }
Example #9
0
        /// <summary>
        /// Returns List of all products
        /// </summary>
        /// <returns></returns>
        public List <Customer> GetAllProductList()
        {
            List <Customer> listCustomer = new List <Customer>();

            using (var context = new InvoiceGenEntities())
            {
                listCustomer = (from a in context.Customers
                                where a.IsActive == true
                                select a).ToList();
            }
            return(listCustomer);
        }
Example #10
0
        public List <ProductsMaster> GetProductListByProductName(string productName)
        {
            List <ProductsMaster> listProduct = new List <ProductsMaster>();

            using (var context = new InvoiceGenEntities())
            {
                listProduct = (from a in context.ProductsMasters
                               where a.Name.Contains(productName)
                               select a).ToList();
            }
            return(listProduct);
        }
Example #11
0
        public List <ProductsMaster> GetProducListByHSNSACCode(string hSNPrefix)
        {
            List <ProductsMaster> listProduct = new List <ProductsMaster>();

            using (var context = new InvoiceGenEntities())
            {
                listProduct = (from a in context.ProductsMasters
                               where a.HSNCode.Contains(hSNPrefix) || a.SACCode.Contains(hSNPrefix)
                               select a).ToList();
            }
            return(listProduct);
        }
Example #12
0
        public UserMaster GetUserdetailsByUsername(string name)
        {
            UserMaster userMaster = new UserMaster();

            using (var context = new InvoiceGenEntities())
            {
                userMaster = (from a in context.UserMasters
                              where a.UserName == name
                              select a).FirstOrDefault();
            }
            return(userMaster);
        }
Example #13
0
        public List <State> GetStateList()
        {
            List <State> listSate = new List <State>();

            using (var context = new InvoiceGenEntities())
            {
                listSate = (from a in context.States
                            where a.Name != null
                            select a).ToList();
            }

            return(listSate);
        }
Example #14
0
        public List <City> GetCityByStateID(string selectedState)
        {
            List <City> listCity = new List <City>();
            int         id       = Convert.ToInt32(selectedState);

            using (var context = new InvoiceGenEntities())
            {
                listCity = (from a in context.Cities
                            where a.StateID == id
                            select a).ToList();
            }
            return(listCity);
        }
Example #15
0
        public State GetStateByID(string number)
        {
            State state = new State();
            var   query = "select s.Name,s.ID,null as country_id from GstStateCodes gst inner join States s on s.ID = gst.StateID where gst.GSTStateCode =";

            query += Convert.ToString(number) + " ";
            using (var context = new InvoiceGenEntities())
            {
                state = context.States
                        .SqlQuery(query)
                        .FirstOrDefault();
            }
            return(state);
        }
Example #16
0
 public bool CreateNewProductBillMapping(BillProductMapping productBillMapp)
 {
     using (var context = new InvoiceGenEntities())
     {
         context.BillProductMappings.Add(productBillMapp);
         context.SaveChanges();//this generates the Id for customer
     }
     if (productBillMapp.ID > 0)
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
Example #17
0
        public string GetStateNameByID(long?stateID)
        {
            State state = new State();

            using (var context = new InvoiceGenEntities())
            {
                state = (from a in context.States
                         where a.ID == stateID
                         select a).FirstOrDefault();
            }
            if (state != null)
            {
                return(state.Name);
            }
            else
            {
                return(string.Format("State with ID:{0} Not Found !", stateID));
            }
        }
Example #18
0
        public string GetCityNameByID(long?cityID)
        {
            City city = new City();

            using (var context = new InvoiceGenEntities())
            {
                city = (from a in context.Cities
                        where a.ID == cityID
                        select a).FirstOrDefault();
            }
            if (city != null)
            {
                return(city.Name);
            }
            else
            {
                return(string.Format("City with ID:{0} Not Found !", cityID));
            }
        }
Example #19
0
 /// <summary>
 /// Saves List of Products to Database
 /// </summary>
 /// <param name="listProduct"></param>
 public List <ProductsMaster> SaveProductsData(List <ProductsMaster> listProduct)
 {
     using (var context = new InvoiceGenEntities())
     {
         try
         {
             foreach (var product in listProduct)
             {
                 ProductsMaster prod = new ProductsMaster();
                 if (product.HSNCode != null)
                 {
                     prod = context.ProductsMasters.SqlQuery("Select * from ProductsMaster where HSNCode=@HSNCode", new SqlParameter("@HSNCode", product.HSNCode)).FirstOrDefault();
                 }
                 else if (product.SACCode != null)
                 {
                     prod = context.ProductsMasters.SqlQuery("Select * from ProductsMaster where SACCode=@SACCode", new SqlParameter("@SACCode", product.SACCode)).FirstOrDefault();
                 }
                 if (prod == null)
                 {
                     context.ProductsMasters.Add(product);
                     context.SaveChanges();
                 }
             }
         }
         catch (DbEntityValidationException e)
         {
             foreach (var eve in e.EntityValidationErrors)
             {
                 foreach (var ve in eve.ValidationErrors)
                 {
                     throw new Exception(string.Format("- Property: \"{0}\", Error: \"{1}\"",
                                                       ve.PropertyName, ve.ErrorMessage));
                 }
             }
         }
         catch (Exception ex)
         {
             throw ex;
         }
         return(listProduct);
     }
 }
Example #20
0
        public string GetUserRole(long userID)
        {
            string role = string.Empty;

            using (var context = new InvoiceGenEntities())
            {
                var userRoleMapping = (from a in context.UserRoleMappings
                                       where a.UserId == userID
                                       select a).FirstOrDefault();

                var rolemaster = (from a in context.RoleMasters
                                  where a.ID == userRoleMapping.RoleId
                                  select a).FirstOrDefault();
                if (rolemaster != null)
                {
                    role = rolemaster.RoleName;
                }
            }
            return(role);
        }
Example #21
0
        public bool CheckIfCustomerExistByName(string name, out long customerID)
        {
            customerID = -1;
            Customer customer = new Customer();

            using (var context = new InvoiceGenEntities())
            {
                customer = (from a in context.Customers
                            where a.IsActive == true && a.Name == name
                            select a).FirstOrDefault();
            }
            if (customer == null)
            {
                return(false);
            }
            else
            {
                customerID = customer.ID;
                return(true);
            }
        }
Example #22
0
        public bool CheckIfProductExistBySACode(string sACCode, out long productID)
        {
            productID = -1;
            ProductsMaster productsMaster = new ProductsMaster();

            using (var context = new InvoiceGenEntities())
            {
                productsMaster = (from a in context.ProductsMasters
                                  where a.SACCode == sACCode
                                  select a).FirstOrDefault();
            }
            if (productsMaster != null)
            {
                productID = productsMaster.ID;
                return(true);
            }
            else
            {
                return(false);
            }
        }