예제 #1
0
        public static UserOrganization ToUserOrganizationEntity(bool IsActive, UserBO User, OrganizationBO Organization)
        {
            UserOrganization UserOrganization = new UserOrganization();

            UserOrganization.Active = IsActive;

            UserOrganization.RoleId = User.Role;

            User         UserInfo         = new EF.User();
            Organization OrganizationInfo = new EF.Organization();

            UserInfo.EmailAddress  = User.EmailAddress;
            UserInfo.UserName      = User.EmailAddress;
            UserInfo.LastName      = User.LastName;
            UserInfo.FirstName     = User.FirstName;
            UserInfo.PhoneNumber   = User.PhoneNumber;
            UserInfo.ResetPassword = User.ResetPassword; //false;
            UserInfo.PasswordHash  = User.PasswordHash;  //"PassWord1";
            UserInfo.UGuid         = User.UGuid;
            UserOrganization.User  = UserInfo;


            OrganizationInfo.Organization1   = Organization.Organization;
            OrganizationInfo.IsEnabled       = Organization.IsEnabled;
            OrganizationInfo.OrganizationKey = Organization.OrganizationKey;

            UserOrganization.Organization = OrganizationInfo;

            return(UserOrganization);
        }
        public bool InsertUser(UserBO User, OrganizationBO OrgBO)
        {
            try
            {
                User.UGuid = Guid.NewGuid();
                using (var Context = DataObjectFactory.CreateContext())
                {
                    var Org = Context.Organizations.Where(x => x.OrganizationId == OrgBO.OrganizationId).Single();

                    Context.Organizations.Attach(Org);



                    Context.Users.Add(Mapper.ToUserEntity(User));

                    UserOrganization UserOrganizationEntity = Mapper.ToUserOrganizationEntity(User, OrgBO);
                    Context.UserOrganizations.Add(UserOrganizationEntity);



                    Context.SaveChanges();
                }
                return(true);
            }
            catch (Exception ex)
            {
                throw (ex);
            }
        }
        public bool UpdateUserInfo(UserBO User, OrganizationBO OrgBO)
        {
            try
            {
                using (var Context = DataObjectFactory.CreateContext())
                {
                    User user = Context.Users.First(x => x.UserID == User.UserId);
                    // user.UserName = User.UserName;
                    user.EmailAddress = User.EmailAddress;
                    user.FirstName    = User.FirstName;
                    user.LastName     = User.LastName;

                    UserOrganization UserOrganization = Context.UserOrganizations.First(x => x.OrganizationID == OrgBO.OrganizationId && x.UserID == User.UserId);
                    UserOrganization.RoleId = User.Role;
                    UserOrganization.Active = User.IsActive;

                    Context.SaveChanges();
                }
                return(true);
            }
            catch (Exception ex)
            {
                throw (ex);
            }
        }
예제 #4
0
        public static UserOrganization ToUserOrganizationEntity(UserBO User, OrganizationBO Organization)
        {
            UserOrganization UserOrganization = new UserOrganization();

            UserOrganization.Active         = User.IsActive;
            UserOrganization.RoleId         = User.Role;
            UserOrganization.OrganizationID = Organization.OrganizationId;


            return(UserOrganization);
        }
예제 #5
0
파일: Mapper.cs 프로젝트: fgma75/epiinfo
        internal static UserOrganization ToUserOrganizationEntity(UserBO User, OrganizationBO Organization)
        {
            UserOrganization UserOrganization = new UserOrganization();

            UserOrganization.Active         = User.IsActive;
            UserOrganization.RoleId         = User.Role;
            UserOrganization.OrganizationID = Organization.OrganizationId;
            UserOrganization.UserID         = User.UserId;
            //UserOrganization.Role = User.Role;
            return(UserOrganization);
        }
        public bool UpdateUserOrganization(UserBO User, OrganizationBO OrgBO)
        {
            UserOrganization UserOrganizationEntity = Mapper.ToUserOrganizationEntity(User, OrgBO);

            using (var Context = DataObjectFactory.CreateContext())
            {
                UserOrganizationEntity.UserID = User.UserId;
                Context.UserOrganizations.Add(UserOrganizationEntity);
                Context.SaveChanges();

                return(true);
            }
        }
예제 #7
0
        public bool InsertOrganization(OrganizationBO Organization, int UserId, int RoleId)
        {
            try
            {
                UserOrganization UserOrganizationEntity = Mapper.ToUserOrganizationEntity(Organization.IsEnabled, UserId, RoleId, Organization);
                using (var Context = DataObjectFactory.CreateContext())
                {
                    Context.UserOrganizations.Add(UserOrganizationEntity);

                    Context.SaveChanges();
                    return(true);
                }
            }
            catch (Exception ex)
            {
                throw (ex);
            }
        }
예제 #8
0
        public static UserOrganization ToUserOrganizationEntity(bool IsActive, int UserId, int RoleId, OrganizationBO Organization)
        {
            UserOrganization UserOrganization = new UserOrganization();

            UserOrganization.Active = IsActive;

            UserOrganization.RoleId = RoleId;
            UserOrganization.UserID = UserId;

            Organization OrganizationInfo = new EF.Organization();



            OrganizationInfo.Organization1   = Organization.Organization;
            OrganizationInfo.IsEnabled       = Organization.IsEnabled;
            OrganizationInfo.OrganizationKey = Organization.OrganizationKey;
            OrganizationInfo.OrganizationId  = Organization.OrganizationId;
            UserOrganization.Organization    = OrganizationInfo;

            return(UserOrganization);
        }