Exemple #1
0
 public void ChangeStatus(UserInfo userInfo)
 {
     throw new NotImplementedException();
 }
Exemple #2
0
 private bool Insert(UserInfo entUser)
 {
     TCRepositoryDataContext context = DataBaseUtils.GetContext();
     try
     {
         tbl_Users dbUser = new tbl_Users()
         {
             FirstName = entUser.FirstName,
             LastName = entUser.LastName,
             UserName = entUser.UserName,
             HashCode = entUser.HashCode,
             Password = entUser.Password,
             CreatedOn = DateTime.Now,
             Email = entUser.Email,
             IdCompany = entUser.EntCompany.IdCompany,
             IdStatus = entUser.EntStatus.IdStatus,
             IdRole = entUser.EntRole.IdRole,
             ModifiedOn = DateTime.Now
         };
         context.tbl_Users.InsertOnSubmit(dbUser);
         context.SubmitChanges();
         return true;
     }
     catch
     { }
     return false;
 }
Exemple #3
0
        private bool Update(UserInfo entUser)
        {
            TCRepositoryDataContext context = DataBaseUtils.GetContext();
            try
            {
                tbl_Users dbUser = context.tbl_Users.Where(u => u.IdUser == entUser.IdUser).FirstOrDefault();
                dbUser.FirstName = entUser.FirstName;
                dbUser.LastName = entUser.LastName;
                dbUser.UserName = entUser.UserName;
                dbUser.Password = entUser.Password;
                dbUser.ModifiedOn = DateTime.Now;
                dbUser.HashCode = entUser.HashCode;
                dbUser.Email = entUser.Email;
                dbUser.IdCompany = entUser.EntCompany.IdCompany;
                dbUser.IdRole = entUser.EntRole.IdRole;
                dbUser.IdStatus = entUser.EntStatus.IdStatus;

                context.SubmitChanges();
                return true;
            }
            catch
            { }
            return false;
        }
Exemple #4
0
 private void AssignDataObjectToEntity(tbl_Users dbUser, ref UserInfo entUserInfo)
 {
     entUserInfo.UserCompleteName = String.Format("{0} {1}", dbUser.FirstName, dbUser.LastName);
     entUserInfo.IdUser = dbUser.IdUser;
     entUserInfo.UserName = dbUser.UserName;
     entUserInfo.FirstName = dbUser.FirstName;
     entUserInfo.LastName = dbUser.LastName;
     entUserInfo.Password = dbUser.Password;
     entUserInfo.HashCode = dbUser.HashCode;
     entUserInfo.CreatedOn = dbUser.CreatedOn;
     entUserInfo.ModifiedOn = dbUser.ModifiedOn;
     entUserInfo.EntCompany = new DataAccessLibrary.Services.CompanyService().GetByID(dbUser.IdCompany);
     entUserInfo.EntStatus = new DataAccessLibrary.Services.StatusService().GetById(dbUser.IdStatus);
     entUserInfo.EntRole = new RoleService().GetRoleByID(dbUser.IdRole);
     entUserInfo.Email = dbUser.Email;
 }
Exemple #5
0
        public bool Save(UserInfo newUser)
        {
            TCRepositoryDataContext context = DataBaseUtils.GetContext();
            bool blResult =false;
            try
            {

                if (newUser.IdUser == 0)
                    blResult = Insert(newUser);
                else
                    blResult = Update(newUser);
            }
            catch
            {
                return false;
            }
            return blResult;
        }
Exemple #6
0
        public List<UserInfo> GetUsersDDL()
        {
            TCRepositoryDataContext context = DataBaseUtils.GetContext();
            //DataSet dsUser = mscConnector.GetDataFromQuery(uqQuery.SelectAll());
            List<tbl_Users> dbListUsers = context.tbl_Users.Where(u => u.IdStatus == 1).ToList();

            List<UserInfo> entUserInfoList = new List<UserInfo>();

            foreach (var drUserInfo in dbListUsers)
            {
                UserInfo entUserInfo = new UserInfo();
                AssignDataObjectToEntity(drUserInfo, ref entUserInfo);
                entUserInfoList.Add(entUserInfo);
            }

            UserInfo entItem = new UserInfo() { IdUser = -1, FirstName = "Selecciona..." };
            entUserInfoList.Insert(0, entItem);
            return entUserInfoList;
        }
Exemple #7
0
        public List<UserInfo> GetUsers(string userName, int startRowIndex, int maximumRows)
        {
            TCRepositoryDataContext context = DataBaseUtils.GetContext();
            List<tbl_Users> dbListUsers = context.tbl_Users.ToList();

            List<UserInfo> entUserInfoList = new List<UserInfo>();

            foreach (var drUserInfo in dbListUsers)
            {
                UserInfo entUserInfo = new UserInfo();
                AssignDataObjectToEntity(drUserInfo, ref entUserInfo);
                entUserInfoList.Add(entUserInfo);
            }

            return entUserInfoList;
        }
Exemple #8
0
        public UserInfo GetUserById(int idUser)
        {
            TCRepositoryDataContext context = DataBaseUtils.GetContext();
            tbl_Users dbUser = context.tbl_Users.Where(u => u.IdUser== idUser).FirstOrDefault();

            UserInfo entUser = new UserInfo();
            if (dbUser!=null)
            {
                AssignDataObjectToEntity(dbUser, ref entUser);
            }
            else
            {
                return null;
            }
            return entUser;
        }