Example #1
0
 public MemberBO GetMemberByEmail(string email)
 {
     using (var context = new InThuDoEntities())
     {
         var member = context.Users.FirstOrDefault(c => c.Email == email) as User;
         return(Mapper.Map <User, MemberBO>(member));
     }
 }
Example #2
0
 public List<RoleTypeBO> GetRoleTypes()
 {
     using (var context = new InThuDoEntities())
     {
         var roles = context.LibRoleTypes.ToList();
         return Mapper.Map<List<LibRoleType>, List<RoleTypeBO>>(roles);
     }
 }
Example #3
0
 public List<BusinessObjects.ProductBO> GetAllProducts()
 {
     using (var context = new InThuDoEntities())
     {
         var query = context.Products.ToList();
         return Mapper.Map<List<Product>, List<BusinessObjects.ProductBO>>(query);
     }
 }
Example #4
0
 public MemberBO GetMemberByTelephone(string telephone)
 {
     using (var context = new InThuDoEntities())
     {
         var member = context.Users.FirstOrDefault(c => c.Telephone == telephone) as User;
         return(Mapper.Map <User, MemberBO>(member));
     }
 }
Example #5
0
 public List <RoleTypeBO> GetRoleTypes()
 {
     using (var context = new InThuDoEntities())
     {
         var roles = context.LibRoleTypes.ToList();
         return(Mapper.Map <List <LibRoleType>, List <RoleTypeBO> >(roles));
     }
 }
Example #6
0
        public void DeleteMember(MemberBO member)
        {
            using (var context = new InThuDoEntities())
            {
                var entity = context.Users.SingleOrDefault(m => m.UserId == member.UserId);
                entity.Deteted = true;

                context.SaveChanges();
            }
        }
Example #7
0
        public void DeleteMember(MemberBO member)
        {
            using (var context = new InThuDoEntities())
            {
                var entity = context.Users.SingleOrDefault(m => m.UserId == member.UserId);
                entity.Deteted = true;

                context.SaveChanges();
            }
        }
Example #8
0
 public void ChangePass(int userId, string pass)
 {
     using (var context = new InThuDoEntities())
     {
         var mem = context.Users.SingleOrDefault(m => m.UserId == userId);
         if (mem == null) return;
         mem.Password = pass;
         context.SaveChanges();
     }
 }
Example #9
0
 public CustomerTypeBO GetCustomerTypeById(int id)
 {
     using (var context = new InThuDoEntities())
     {
         var query = from c in context.LibCustomerTypes
                     where c.Id== id
                     select c;
         if (query.Count() == 0) return null;
         return this.MapCustomerType(query.FirstOrDefault());
     }
 }
Example #10
0
        public CustomerBO GetCustomerById(int custId)
        {
            using (var context = new InThuDoEntities())
            {
                var query = from c in context.Customers
                            where c.CustomerId == custId
                            select c;
                return MapCustomer(query.FirstOrDefault());

            }
        }
Example #11
0
 public int GetCustomerTypeId(string code)
 {
     using (var context = new InThuDoEntities())
     {
         var query = from c in context.LibCustomerTypes
                     where c.Code == code
                         select c;
         if (query.Count() == 0) return 0;
         return query.FirstOrDefault().Id;
     }
 }
Example #12
0
 public void MarkCustomerAsDeleted(int custId)
 {
     using (var context = new InThuDoEntities())
     {
         Customer cust = (from c in context.Customers
                          where c.CustomerId == custId
                          select c).FirstOrDefault();
         cust.Deleted = true;
         context.SaveChanges();
     }
 }
Example #13
0
 public CustomerBO GetCustomerByOrder(int orderId)
 {
     using (var context = new InThuDoEntities())
     {
         var query = from c in context.Customers
                     join o in context.Orders on c.CustomerId equals o.CustomerId
                     where o.OrderId == orderId
                     select c;
         return MapCustomer(query.FirstOrDefault());
     }
 }
Example #14
0
        public string GetStringSetting(string name)
        {
            using (var context = new InThuDoEntities())
            {
                var query = from s in context.Settings
                            where s.Name == name
                            select s;
                if (query.FirstOrDefault() == null) return string.Empty;

                return query.FirstOrDefault().Value;
            }
        }
Example #15
0
        public void DeleteUserOrganizationMapping(int memberId, int organizationId)
        {
            using (var context = new InThuDoEntities())
            {
                UserOrganizationMappping userOrganizationMap = context.UserOrganizationMapppings.Where(uo => uo.UserId == memberId && uo.OrganizationId == organizationId).FirstOrDefault();
                if (userOrganizationMap == null)
                    return;

                context.UserOrganizationMapppings.Remove(userOrganizationMap);
                context.SaveChanges();
            }
        }
Example #16
0
 public bool GetBoolSetting(string name)
 {
     using (var context = new InThuDoEntities())
     {
         var query = from s in context.Settings
                     where s.Name == name
                     select s;
         bool result = false;
         bool.TryParse(query.FirstOrDefault().Value, out result);
         return result;
     }
 }
Example #17
0
 public List<DepartmentBO> GetAllDepartment()
 {
     using (var context = new InThuDoEntities())
     {
         var query = from d in context.LibDepartments
                     select new DepartmentBO() {
                         DepartmentId = d.DepartmentId,
                         Name = d.Name,
                         Description = d.Description
                     };
         return query.ToList();
     }
 }
Example #18
0
        public int InsertMember(MemberBO member)
        {
            using (var context = new InThuDoEntities())
            {
                var entity = Mapper.Map <MemberBO, User>(member);

                context.Users.Add(entity);
                context.SaveChanges();

                // update business object with new id
                return(entity.UserId);
            }
        }
Example #19
0
 public List<DepositMethodBO> GetAllDepositMethod()
 {
     using (var context = new InThuDoEntities())
     {
         return (from d in context.LibDepositTypes
                 select new DepositMethodBO()
                 {
                     DepositTypeId = d.DepositTypeId,
                     Name = d.Name,
                     Description = d.Description
                 }).ToList();
     }
 }
Example #20
0
 public void ChangePass(int userId, string pass)
 {
     using (var context = new InThuDoEntities())
     {
         var mem = context.Users.SingleOrDefault(m => m.UserId == userId);
         if (mem == null)
         {
             return;
         }
         mem.Password = pass;
         context.SaveChanges();
     }
 }
Example #21
0
 public List<OrganizationBO> GetAllOrganizations()
 {
     using (var context = new InThuDoEntities())
     {
         var query = from og in context.Organizations
                     select new OrganizationBO()
                     {
                         OrganizationId = og.OrganizationId,
                         Name = og.Name
                     };
         return query.Distinct().ToList();
     }
 }
Example #22
0
 public List<OrderStatusBO> GetAllOrderStatus()
 {
     using (var context = new InThuDoEntities())
     {
         return (from status in context.LibOrderStatus
                 select new OrderStatusBO()
                 {
                     OrderStatusId = status.OrderStatusId,
                     Name = status.Name,
                     Description = status.Description,
                     ProcessingOrder = status.ProcessingOrder
                 }).ToList();
     }
 }
Example #23
0
        public void DeleteUserOrganizationMapping(int memberId, int organizationId)
        {
            using (var context = new InThuDoEntities())
            {
                UserOrganizationMappping userOrganizationMap = context.UserOrganizationMapppings.Where(uo => uo.UserId == memberId && uo.OrganizationId == organizationId).FirstOrDefault();
                if (userOrganizationMap == null)
                {
                    return;
                }

                context.UserOrganizationMapppings.Remove(userOrganizationMap);
                context.SaveChanges();
            }
        }
Example #24
0
        public void InsertUserOrganizationMapping(int memberId, int organizationId)
        {
            using (var context = new InThuDoEntities())
            {
                UserOrganizationMappping userOrganization = new UserOrganizationMappping()
                {
                    OrganizationId = organizationId,
                    UserId         = memberId,
                };

                context.UserOrganizationMapppings.Add(userOrganization);
                context.SaveChanges();
            }
        }
Example #25
0
 public List <DepartmentBO> GetAllDepartment()
 {
     using (var context = new InThuDoEntities())
     {
         var query = from d in context.LibDepartments
                     select new DepartmentBO()
         {
             DepartmentId = d.DepartmentId,
             Name         = d.Name,
             Description  = d.Description
         };
         return(query.ToList());
     }
 }
Example #26
0
 public int InsertProduct(string productName)
 {
     using (var context = new InThuDoEntities())
     {
         Product p = new Product()
         {
             Name = productName
         };
         context.Entry(p).State = System.Data.EntityState.Added;
         context.Products.Add(p);
         context.SaveChanges();
         return p.ProductId;
     }
 }
Example #27
0
 public ProductBO GetProductByName(string productName)
 {
     using (var context = new InThuDoEntities())
     {
         var query = (from p in context.Products
                     where p.Name == productName
                     select new ProductBO() {
                         ProductId = p.ProductId,
                         Name = p.Name,
                         Description=p.Description
                     }).FirstOrDefault();
         return query;
     }
 }
Example #28
0
        public List<string> GetProductNames(string prefixText)
        {
            using (var context = new InThuDoEntities())
            {
                List<string> result = new List<string>();
                var query = from p in context.Products
                             where p.Name.Contains(prefixText)
                             select p;
                foreach(Product p in query)
                {
                    result.Add(p.Name);
                }
                return result;

            }
        }
Example #29
0
 public void UpdateMember(MemberBO member)
 {
     using (var context = new InThuDoEntities())
     {
         var entity = context.Users.SingleOrDefault(m => m.UserId == member.UserId);
         entity.Email        = member.Email;
         entity.UserName     = member.UserName;
         entity.Address      = member.Address;
         entity.Telephone    = member.Telephone;
         entity.RoleTypeId   = member.RoleTypeId;
         entity.LastEditedOn = member.LastEditedOn;
         entity.FullName     = member.FullName;
         entity.DepartmentId = member.DepartmentId;
         //context.Members.Attach(entity);
         context.SaveChanges();
     }
 }
Example #30
0
        public List<CustomerBO> GetCustomers(string customerName, string telephone, string email, string companyName, int customerTypeId)
        {
            using (var context = new InThuDoEntities())
            {
                var query = from c in context.Customers
                            where
                            (string.IsNullOrEmpty(customerName) || c.Name.Contains(customerName)) &&
                            (string.IsNullOrEmpty(telephone) || c.Telephone.Contains(telephone)) &&
                            (string.IsNullOrEmpty(email) || c.Email.Contains(email)) &&
                            (string.IsNullOrEmpty(companyName) || c.Company.Contains(companyName)) &&
                            (customerTypeId ==0 || c.CustomerTypeId == customerTypeId)&&
                            (c.Deleted == false || c.Deleted == null)
                            select c;

                return MapCustomerList(query);
            }
        }
Example #31
0
        public List<OrganizationBO> GetAllOrganization()
        {
            using (var context = new InThuDoEntities())
            {
                var query = from or in context.Organizations
                            select new OrganizationBO() {
                                OrganizationId = or.OrganizationId,
                                Name = or.Name,
                                Address = or.Address,
                                Description = or.Description,
                                FaxNumber = or.FaxNumber,
                                PhoneNumber = or.PhoneNumber,
                                TaxCode = or.TaxCode
                            };
                if (query == null) return new List<OrganizationBO>();

                return query.ToList();
            }
        }
Example #32
0
 public MemberBO GetMemberByUserName(string userName)
 {
     using (var context = new InThuDoEntities())
     {
         var member = context.Users.FirstOrDefault(c => c.UserName == userName) as User;
         var result = Mapper.Map <User, MemberBO>(member);
         if (result != null)
         {
             result.Department = new DepartmentBO()
             {
                 DepartmentId = member.LibDepartment.DepartmentId,
                 Code         = member.LibDepartment.Code,
                 Name         = member.LibDepartment.Name,
                 Description  = member.LibDepartment.Description
             };
         }
         return(result);
     }
 }
Example #33
0
        public List <MemberBO> GetMembers(string username, string email, string fullName, string telephone, int roletypeId, int departId, int organizationId)
        {
            using (var context = new InThuDoEntities())
            {
                var query = from mem in context.Users
                            join uom in context.UserOrganizationMapppings on mem.UserId equals uom.UserId into uomGroup
                            from uom2 in uomGroup.DefaultIfEmpty()
                            where
                            (String.IsNullOrEmpty(username) || mem.UserName.Contains(username)) &&
                            (String.IsNullOrEmpty(email) || mem.Email.Contains(email)) &&
                            (String.IsNullOrEmpty(fullName) || mem.FullName.Contains(fullName)) &&
                            (String.IsNullOrEmpty(telephone) || mem.FullName.Contains(telephone)) &&
                            (roletypeId == 0 || mem.RoleTypeId == roletypeId) &&
                            (departId == 0 || mem.DepartmentId == departId) &&
                            (organizationId == 0 || uom2.OrganizationId == organizationId) &&
                            (mem.Deteted == null || mem.Deteted == false)
                            select mem;

                var roles = context.LibRoleTypes;
                return(query.ToList().AsQueryable().Select(m =>
                                                           new MemberBO
                {
                    UserId = m.UserId,
                    Email = m.Email,
                    DepartmentId = m.DepartmentId,
                    RoleType = Mapper.Map <LibRoleType, RoleTypeBO>(roles.Where(r => r.RoleTypeId == m.RoleTypeId).FirstOrDefault()),
                    FullName = m.FullName,
                    Address = m.Address,
                    Telephone = m.Telephone,
                    UserName = m.UserName,
                    Department = new DepartmentBO()
                    {
                        DepartmentId = m.LibDepartment.DepartmentId,
                        Code = m.LibDepartment.Code,
                        Name = m.LibDepartment.Name,
                        Description = m.LibDepartment.Description
                    }
                }
                                                           )
                       .ToList());
            }
        }
Example #34
0
 public MemberBO GetMemberByOrder(int orderId)
 {
     using (var context = new InThuDoEntities())
     {
         var query = from u in context.Users
                     join o in context.Orders on u.UserId equals o.UserId
                     where
                     (o.OrderId == orderId)
                     select new MemberBO()
         {
             UserId    = u.UserId,
             Email     = u.Email,
             FullName  = u.FullName,
             Address   = u.Address,
             Telephone = u.Telephone,
             UserName  = u.UserName
         };
         return(query.FirstOrDefault());
     }
 }
Example #35
0
        public bool Login(string user, string pass)
        {
            using (var context = new InThuDoEntities())
            {
                var query = (from u in context.Users
                             join d in context.LibDepartments on u.DepartmentId equals d.DepartmentId
                             join o in context.UserOrganizationMapppings on u.UserId equals o.UserId
                             where
                             (u.Deteted == false || u.Deteted == null) &&
                             (u.UserName == user) &&
                             (u.Password == pass)
                             select u).Distinct().ToList();

                if (query.Count() == 1)
                {
                    return(true);
                }
                return(false);
            }
        }
Example #36
0
 public List <MemberBO> GetBusinessMen(List <int> orgsId)
 {
     using (var context = new InThuDoEntities())
     {
         var query = from m in context.Users
                     join d in context.LibDepartments on m.DepartmentId equals d.DepartmentId
                     join o in context.UserOrganizationMapppings on m.UserId equals o.UserId
                     where
                     (m.Deteted == false || m.Deteted == null) &&
                     (d.Code == "PKD") &&
                     (orgsId.Count == 0 || orgsId.Contains(o.OrganizationId))
                     select new MemberBO()
         {
             UserId   = m.UserId,
             UserName = m.UserName,
             FullName = m.FullName,
         };
         return(query.Distinct().ToList());
     }
 }
Example #37
0
        public List<PrintingTypeBO> GetAllPrintingType()
        {
            using (var context = new InThuDoEntities())
            {
                var query = (from pt in context.LibPrintingTypes
                            select pt).ToList();

                List<PrintingTypeBO> printingTypes = new List<PrintingTypeBO>();
                foreach (LibPrintingType p in query)
                {
                    PrintingTypeBO printingType = new PrintingTypeBO()
                    {
                        Id = p.Id,
                        Code = p.Code,
                        Name = p.Name,
                        Description = p.Description,
                    };
                    printingTypes.Add(printingType);
                }

                return printingTypes;
            }
        }
Example #38
0
        public List <OrganizationBO> GetAllOrganization()
        {
            using (var context = new InThuDoEntities())
            {
                var query = from or in context.Organizations
                            select new OrganizationBO()
                {
                    OrganizationId = or.OrganizationId,
                    Name           = or.Name,
                    Address        = or.Address,
                    Description    = or.Description,
                    FaxNumber      = or.FaxNumber,
                    PhoneNumber    = or.PhoneNumber,
                    TaxCode        = or.TaxCode
                };
                if (query == null)
                {
                    return(new List <OrganizationBO>());
                }

                return(query.ToList());
            }
        }
Example #39
0
 public MemberBO GetMemberByTelephone(string telephone)
 {
     using (var context = new InThuDoEntities())
     {
         var member = context.Users.FirstOrDefault(c => c.Telephone== telephone) as User;
         return Mapper.Map<User, MemberBO>(member);
     }
 }
Example #40
0
        public void InsertUserOrganizationMapping(int memberId, int organizationId)
        {
            using (var context = new InThuDoEntities())
            {
                UserOrganizationMappping userOrganization = new UserOrganizationMappping()
                {
                    OrganizationId = organizationId,
                    UserId = memberId,
                };

                context.UserOrganizationMapppings.Add(userOrganization);
                context.SaveChanges();
            }
        }
Example #41
0
        public List<MemberBO> GetMembers(string sortExpression = "UserId ASC")
        {
            using (var context = new InThuDoEntities())
            {

                var members = context.Users.Where(m=> m.Deteted ==false || m.Deteted == null).AsQueryable().OrderBy(sortExpression).ToList();

                var roles = context.LibRoleTypes.ToList();
                return members.AsQueryable().Select(m =>
                    new MemberBO
                    {
                        UserId = m.UserId,
                        Email = m.Email,

                        RoleType = new RoleTypeBO()
                        {
                            RoleTypeId = m.RoleTypeId,
                            RoleName = m.LibRoleType.RoleName,
                            RoleDescription = m.LibRoleType.RoleDescription
                        },
                        FullName = m.FullName,
                        Address = m.Address,
                        Telephone = m.Telephone,
                        UserName = m.UserName,
                        Department = new DepartmentBO()
                        {
                            DepartmentId = m.LibDepartment.DepartmentId,
                            Code = m.LibDepartment.Code,
                            Name = m.LibDepartment.Name,
                            Description = m.LibDepartment.Description
                        }
                    }
               )
               .ToList();

                //return Mapper.Map<List<User>, List<Member>>(members);
            }
        }
Example #42
0
 public MemberBO GetMemberByUserName(string userName)
 {
     using (var context = new InThuDoEntities())
     {
         var member = context.Users.FirstOrDefault(c => c.UserName == userName) as User;
         var result = Mapper.Map<User, MemberBO>(member);
         if (result != null)
         {
             result.Department = new DepartmentBO()
             {
                 DepartmentId = member.LibDepartment.DepartmentId,
                 Code = member.LibDepartment.Code,
                 Name = member.LibDepartment.Name,
                 Description = member.LibDepartment.Description
             };
         }
         return result;
     }
 }
Example #43
0
        public List<MemberBO> GetMembers(string username, string email, string fullName, string telephone, int roletypeId, int departId, int organizationId)
        {
            using (var context = new InThuDoEntities())
            {
                var query = from mem in context.Users
                            join uom in context.UserOrganizationMapppings on mem.UserId equals uom.UserId into uomGroup
                            from uom2 in uomGroup.DefaultIfEmpty()
                            where
                            (String.IsNullOrEmpty(username) || mem.UserName.Contains(username))&&
                            (String.IsNullOrEmpty(email) || mem.Email.Contains(email))&&
                            (String.IsNullOrEmpty(fullName)|| mem.FullName.Contains(fullName))&&
                            (String.IsNullOrEmpty(telephone)|| mem.FullName.Contains(telephone))&&
                            (roletypeId ==0 || mem.RoleTypeId == roletypeId)&&
                            (departId == 0 || mem.DepartmentId == departId)&&
                            (organizationId ==0 || uom2.OrganizationId == organizationId)&&
                            (mem.Deteted == null || mem.Deteted == false)
                            select mem;

                var roles = context.LibRoleTypes;
                return query.ToList().AsQueryable().Select(m =>
                    new MemberBO
                    {
                        UserId = m.UserId,
                        Email = m.Email,
                        DepartmentId = m.DepartmentId,
                        RoleType = Mapper.Map<LibRoleType, RoleTypeBO>(roles.Where(r => r.RoleTypeId == m.RoleTypeId).FirstOrDefault()),
                        FullName = m.FullName,
                        Address = m.Address,
                        Telephone = m.Telephone,
                        UserName = m.UserName,
                        Department = new DepartmentBO()
                        {
                            DepartmentId = m.LibDepartment.DepartmentId,
                            Code = m.LibDepartment.Code,
                            Name = m.LibDepartment.Name,
                            Description = m.LibDepartment.Description
                        }
                    }
               )
               .ToList();

            }
        }
Example #44
0
        public List<OrganizationBO> GetOrganizationsByMemberId(int memberId)
        {
            using (var context = new InThuDoEntities())
            {
                var query = from om in context.UserOrganizationMapppings
                            where om.UserId == memberId
                            select new OrganizationBO() {
                                OrganizationId = om.OrganizationId,
                                Name = om.Organization.Name,
                                Address = om.Organization.Address,
                                Description = om.Organization.Description,
                                FaxNumber = om.Organization.FaxNumber,
                                PhoneNumber = om.Organization.PhoneNumber,
                                TaxCode = om.Organization.TaxCode
                            };
                if (query == null) return new List<OrganizationBO>();

                return query.ToList();
            }
        }
Example #45
0
        public int InsertMember(MemberBO member)
        {
            using (var context = new InThuDoEntities())
            {
                var entity = Mapper.Map<MemberBO, User>(member);

                context.Users.Add(entity);
                context.SaveChanges();

                // update business object with new id
                return entity.UserId;
            }
        }
Example #46
0
        public bool Login(string user, string pass)
        {
            using(var context = new InThuDoEntities())
            {
                var query = (from u in context.Users
                            join d in context.LibDepartments on u.DepartmentId equals d.DepartmentId
                            join o in context.UserOrganizationMapppings on u.UserId equals o.UserId
                            where
                            (u.Deteted == false || u.Deteted == null)
                            &&(u.UserName == user)
                            &&(u.Password==pass)
                            select u).Distinct().ToList();

                if (query.Count() == 1)
                {
                    return true;
                }
                return false;

            }
        }
Example #47
0
        public void UpdateMember(MemberBO member)
        {
            using (var context = new InThuDoEntities())
            {
                var entity = context.Users.SingleOrDefault(m => m.UserId == member.UserId);
                entity.Email = member.Email;
                entity.UserName = member.UserName;
                entity.Address = member.Address;
                entity.Telephone = member.Telephone;
                entity.RoleTypeId = member.RoleTypeId;
                entity.LastEditedOn = member.LastEditedOn;
                entity.FullName = member.FullName;
                entity.DepartmentId = member.DepartmentId;
                //context.Members.Attach(entity);
                context.SaveChanges();

            }
        }