示例#1
0
 /// <summary>
 /// 初始化 UserDataProvider 类的新实例。
 /// </summary>
 /// <param name="entity">用户数据实体对象。</param>
 /// <param name="isReadOnly">一个值,该值指示当前对象是否为只读。</param>
 /// <exception cref="ArgumentNullException"/>
 private UserDataProvider(UserProfileEntity entity, bool isReadOnly)
 {
     m_entity       = entity ?? throw new ArgumentNullException(nameof(entity));
     m_nativeHandle = new UserAccessHandle(m_entity.ProfileFileName);
     m_readonly     = isReadOnly;
     m_disposed     = false;
 }
示例#2
0
        public JsonResultEntity Create([FromBody] UserProfileEntity userprofileEntity)
        {
            UserProfileBL    userprofileBL = new UserProfileBL();
            JsonResultEntity response      = new JsonResultEntity();

            return(response);

            try
            {
                var result = userprofileBL.Create(userprofileEntity);

                if (result.HasWarning())
                {
                    response.Message = String.Join(",", result.Warning);
                    return(response);
                }

                response.Success = true;
                response.Data    = result.Value;
            }
            catch (Exception ex)
            {
                response.Message = ex.Message;
                LoggerHelper.Error(ex);
            }

            return(response);
        }
示例#3
0
        static public void SaveWorld()
        {
            List <WorkerEntity> workers = WorkerRepository.Instance.GetAll(1);

            foreach (WorkerEntity worker in workers)
            {
                try
                {
                    PlayerEngineDTO player = PlayerEngineService.Instance.GetById(worker.ExternalId, "rubens");

                    UserProfileEntity user = new UserProfileEntity()
                    {
                        CPF        = player.Cpf,
                        Id         = worker.UserId,
                        Email      = player.Email,
                        LastUpdate = DateTime.Now,
                        Name       = player.Nick,
                        Phone      = "99999999"
                    };

                    UserProfileRepository.Instance.CreateUserProfile(user);
                }
                catch (Exception e)
                {
                    Debug.Print(e.Message + " - " + worker.Id + "\n");
                }
            }
        }
示例#4
0
        public UserProfileEntity Create(UserProfileCreateOrUpdateDto data)
        {
            var entity = new UserProfileEntity
            {
                Name       = data.Name,
                Email      = data.Email,
                SkypeLogin = data.SkypeLogin,
                Signature  = data.Signature,
                ImageUrl   = data.ImageUrl
            };

            // Set role to User
            entity.Role = this.GetDefaultRole();

            // Create settings
            entity.Settings = new UserProfileSettingsEntity
            {
                Enabled = true
            };

            var result = this.DbContext.UserProfiles
                         .Add(entity);

            return(result.Entity);
        }
        public EntityBase Validate(string username, string password, string fiscalYear)
        {
            UserProfileEntity userProfile = new UserProfileEntity();

            userProfile.UserName = username;
            userProfile.Password = password;
            LogDAO Logdao = new DataAccess.Components.LogDAO();

            userProfile = (UserProfileEntity)Logdao.GetValidUser(userProfile);
            if (userProfile == null)
            {
                userProfile             = new UserProfileEntity();
                userProfile.LoginAccess = false;
                userProfile.Remarks     = "No Such User Exists";
            }
            else
            {
                if (userProfile.Accessblocked == true)
                {
                    userProfile.LoginAccess = false;
                    userProfile.Remarks     = "Your Login Has Been Disabled by The Administrator. Contact the Administrator.";
                }
                else
                {
                    userProfile.LoginAccess = true;
                    userProfile.Remarks     = "You have successfuly Logned. Your Profile is being generated please wait.";
                }
            }
            return(userProfile);
        }
示例#6
0
        protected override IDbDataParameter[] CreateSelectParameters(EntityBase anEntity)
        {
            UserProfileEntity       theEntity = (UserProfileEntity)anEntity;
            List <IDbDataParameter> cmdParams = new List <IDbDataParameter>();

            if (!string.IsNullOrEmpty(theEntity.UserName))
            {
                cmdParams.Add(DataAccessFactory.CreateDataParameter("id", theEntity.UserName));
            }

            if (!string.IsNullOrEmpty(theEntity.Password))
            {
                cmdParams.Add(DataAccessFactory.CreateDataParameter("pwd", theEntity.Password));
            }

            if (!string.IsNullOrEmpty(theEntity.FiscalYear))
            {
                cmdParams.Add(DataAccessFactory.CreateDataParameter("fcl_yr", theEntity.FiscalYear));
            }

            // This is the output parameter that is required for Oracle Connection.
            // This is required only when the database is oracle as it will return cursor.

            cmdParams.Add(DataAccessFactory.CreateDataParameter("Result", ""));

            return(cmdParams.ToArray());
        }
        private void PopulateModel(UserModel userModel, UserEntity user, UserProfileEntity userProfile)
        {
            userModel.Religions      = SelectListGenerator.GetSelectedReligions(userProfile);
            userModel.Statuses       = SelectListGenerator.GetSelectedStatuses(userProfile);
            userModel.Orientations   = SelectListGenerator.GetSelectedOrientations(userProfile);
            userModel.Genders        = SelectListGenerator.GetSelectedGenders(userProfile);
            userModel.Email          = user.UserEmail;
            userModel.UserName       = user.UserUsername;
            userModel.Description    = string.IsNullOrWhiteSpace(userProfile.UserProfileDescription) ? "" : userProfile.UserProfileDescription;
            userModel.Phone          = string.IsNullOrWhiteSpace(userProfile.UserProfilePhone) ? "" : userProfile.UserProfilePhone;
            userModel.Job            = string.IsNullOrWhiteSpace(userProfile.UserProfileJob) ? "" : userProfile.UserProfileJob;
            userModel.Name           = userProfile.UserProfileName;
            userModel.Surname        = userProfile.UserProfileSurname;
            userModel.ReligionId     = userProfile.ReligionId;
            userModel.StatusId       = userProfile.StatusId;
            userModel.OrientationId  = userProfile.OrientationId;
            userModel.GenderId       = userProfile.GenderId;
            userModel.Age            = AgeCalculator.GetDifferenceInYears(userProfile.UserProfileBirthday, DateTime.Now);
            userModel.Birthday       = userProfile.UserProfileBirthday;
            userModel.BirthdayString = DateFormatter.GetDate(userProfile.UserProfileBirthday);
            userModel.Starsign       = StarsignCalculator.GetStarsignName(userProfile.UserProfileBirthday);
            userModel.Motto          = string.IsNullOrWhiteSpace(userProfile.Motto) ? "" : userProfile.Motto;

            var prefHandler = new PreferenceHandler();

            userModel.LikesList    = prefHandler.GetAllForUserProfile(userProfile.UserProfileId, true).Entity.ToList();
            userModel.DislikesList = prefHandler.GetAllForUserProfile(userProfile.UserProfileId, false).Entity.ToList();
        }
示例#8
0
        public async Task<UserProfile> GetUserProfile()
        {
            UserIdentityEntity userIdentityEntity = userIdentityRepository.GetAll().LastOrDefault();
            UserProfileEntity userProfileEntity = null;
            userProfile = null;

            if (userIdentityEntity != null && !string.IsNullOrEmpty(userIdentityEntity.Email))
            {
                userProfile = await userService.GetUserProfileByAuthLocalId(userIdentityEntity.LocalId);

                //Below code: tries to get latest data from server (and update cached data), otherwise get from cached data
                if (userProfile == null)
                {
                    Navigator.Instance.OkAlert("Alert", "Currently in offline mode due to issue on server. Your profile is temporarily not synced.", "OK");
                    userProfileEntity = userProfileRepository.GetUserProfile(userIdentityEntity.Email);
                    userProfile = ConvertProfileEntityToUserProfile(userProfileEntity);
                }
                else
                {
                    var row = userProfileRepository.CreateOrUpdate(GetUserProfileEntity());
                    if (row < 0)
                    {
                        Navigator.Instance.OkAlert("Alert", "There is an issue trying to update your profile onto your device from server.", "OK");
                    }
                }
            }

            return userProfile;
        }
        public async Task <DomainProfile> EditAsync(DomainProfile entity)
        {
            UserProfileEntity userProfile = await _profileRepository.SingleAsync(p => p.UserId == entity.UserId);

            if (userProfile == null)
            {
                throw new ApplicationException("Unexpected exception occured!");
            }

            userProfile.UserName = entity.UserName;
            userProfile.City     = entity.City;
            userProfile.Country  = entity.Country;
            userProfile.Timezone = entity.Timezone;
            userProfile.Modified = DateTime.UtcNow;

            userProfile = await _profileRepository.UpdateAsync(userProfile);

            List <StorageSpaceEntity> storageSpace = await _storageSpaceRepository.ToListAsync(p => p.UserId == entity.UserId);

            DomainProfile profile = _mappingEngine.Map <UserProfileEntity, DomainProfile>(userProfile);

            profile.UsedStorageSpace = storageSpace.Where(p => !p.IsArtifact).Sum(p => p.FileLength);

            return(profile);
        }
示例#10
0
        /// <summary>
        /// 在用户数据库中创建一个新的用户实体对象。
        /// </summary>
        /// <param name="username">新用户的用户名。</param>
        /// <returns>新创建的用户的句柄。</returns>
        /// <exception cref="ArgumentNullException"/>
        /// <exception cref="UsernameAlreadyExistsException"/>
        public UserHandle CreateUser(string username)
        {
            if (username == null)
            {
                throw new ArgumentNullException(nameof(username));
            }
            if (IsUserExist(username))
            {
                throw new UsernameAlreadyExistsException(new UserHandle(username));
            }

            UserProfileEntity entity = new UserProfileEntity()
            {
                Username = username,
            };

            // 将实体数据对象添加到数据库中。
            m_factory.WithContext(context =>
            {
                context.AddUserProfileEntity(entity);
                context.SaveChanges();
            });

            return(new UserHandle(username));
        }
        /// <summary>
        /// Deletes the userProfile.
        /// </summary>
        /// <param name="userProfile">The userProfile.</param>
        /// <returns></returns>
        public string DeleteUserProfile(UserProfileEntity userProfile)
        {
            const string sql = @"uspDelete_UserProfile";

            object[] parms = { "@UserProfileID", userProfile.UserProfileId };
            return(Db.Delete(sql, true, parms));
        }
示例#12
0
 /// <summary>
 /// 初始化 UserDataProvider 类的新实例。
 /// </summary>
 /// <param name="context">数据上下文对象。</param>
 /// <param name="entity">用户数据实体对象。</param>
 /// <param name="isReadOnly">一个值,该值指示当前对象是否为只读。</param>
 /// <exception cref="ArgumentNullException"/>
 private UserDataProvider(UserDataContext context, UserProfileEntity entity, bool isReadOnly)
 {
     m_context  = context ?? throw new ArgumentNullException(nameof(context));
     m_entity   = entity ?? throw new ArgumentNullException(nameof(entity));
     m_readonly = isReadOnly;
     m_disposed = false;
 }
示例#13
0
        /// <summary>
        /// 添加给定的用户到给定的队伍中。
        /// </summary>
        /// <param name="team">队伍句柄。</param>
        /// <param name="user">用户句柄。</param>
        /// <exception cref="ArgumentNullException"/>
        /// <exception cref="TeamNotFoundException"/>
        /// <exception cref="UserNotFoundException"/>
        public void AddUserToTeam(TeamHandle team, UserHandle user)
        {
            if (team == null)
            {
                throw new ArgumentNullException(nameof(team));
            }
            if (user == null)
            {
                throw new ArgumentNullException(nameof(user));
            }

            m_factory.WithContext(context =>
            {
                TeamProfileEntity teamEntity = context.QueryTeamProfileEntity(team.TeamId);
                if (teamEntity == null)
                {
                    throw new TeamNotFoundException(team);
                }

                UserProfileEntity userEntity = context.QueryUserProfileEntity(user.Username);
                if (userEntity == null)
                {
                    throw new UserNotFoundException(user);
                }

                teamEntity.Members.Add(userEntity);
                context.SaveChanges();
            });
        }
示例#14
0
        /// <summary>
        /// Creates user, if it does not exist.
        /// Adds a role to the created user and creates user profile.
        /// </summary>
        /// <exception cref="ArgumentNullException"></exception>
        /// <exception cref="AccountException"></exception>
        public async Task Create(UserDTO userDto)
        {
            if (userDto == null)
            {
                throw new ArgumentNullException(nameof(userDto));
            }

            ApplicationUser user = await identityUnitOfWork.UserManager.FindByEmailAsync(userDto.Email);

            if (user == null)
            {
                user = new ApplicationUser {
                    Email = userDto.Email, UserName = userDto.UserName
                };
                await identityUnitOfWork.UserManager.CreateAsync(user, userDto.Password);

                // add role
                await identityUnitOfWork.UserManager.AddToRoleAsync(user.Id, userDto.Role);

                // create user profile
                UserProfileEntity userProfile = new UserProfileEntity {
                    Id = user.Id
                };
                employeeUnitOfWork.Profile.Insert(userProfile);

                await identityUnitOfWork.SaveAsync();

                await employeeUnitOfWork.SaveAsync();
            }
            else
            {
                throw new AccountException("User with such email already exists.");
            }
        }
        public void Save(UserProfileEntity userProfileEntity)
        {
            if (userProfileEntity == null)
            {
                throw new ArgumentNullException(
                          "userProfileEntity",
                          "Can't save null to the user profiles.");
            }
            // Make sure it doesn't exist.  If it does then
            // you're doing it wrong.
            var existingUserProfile = GetUser(userProfileEntity.UserName);

            if (existingUserProfile != null)
            {
                // Nothing to do.
                return;
            }

            var userProfile =
                AssignEntityToModel(userProfileEntity);

            this
            .Context
            .UserProfiles
            .Add(userProfile);

            this.Context.SaveChanges();

            userProfileEntity.UserId = userProfile.UserId;
        }
示例#16
0
        protected override EntityBase CreateAndBuildEntity(DataHelper.Framework.SafeDataReader dr)
        {
            UserProfileEntity theEntity = new UserProfileEntity();

            theEntity.UserName = !dr.IsDBNull(0) ? dr.GetValue(0).ToString() : string.Empty;

            theEntity.FullDetails = !dr.IsDBNull(1) ? dr.GetValue(1).ToString() : string.Empty;

            theEntity.Password = !dr.IsDBNull(5) ? dr.GetValue(5).ToString() : string.Empty;

            theEntity.FiscalYear = !dr.IsDBNull(2) ? dr.GetValue(2).ToString() : string.Empty;

            theEntity.EmployeeName = !dr.IsDBNull(3) ? dr.GetValue(3).ToString() : string.Empty;

            theEntity.UserGroupID = !dr.IsDBNull(4) ? Int32.Parse(dr.GetValue(4).ToString()) : 0;
            theEntity.EmployeeID  = !dr.IsDBNull(12) ? dr.GetValue(12).ToString() : string.Empty;
            if (!dr.IsDBNull(7))
            {
                if (Int32.Parse(dr.GetValue(7).ToString()) == 1)
                {
                    theEntity.Accessblocked = true;
                }
                else
                {
                    theEntity.Accessblocked = false;
                }
            }
            else
            {
                theEntity.Accessblocked = false;
            }

            return(theEntity);
        }
        public UserProfileEntity ToDataEntity(UserModel model, UserProfileEntity userProfile)
        {
            var starSign = new StarSignHandler().GetByName(StarsignCalculator.GetStarsignName(model.Birthday));

            if (!starSign.CompletedRequest)
            {
                return(null);
            }

            return(new UserProfileEntity
            {
                UserProfileId = userProfile.UserProfileId,
                UserAge = AgeCalculator.GetDifferenceInYears(model.Birthday, DateTime.Now),
                UserProfileBirthday = model.Birthday,
                UserProfileName = model.Name,
                UserProfileSurname = model.Surname,
                UserProfileDescription = model.Description,
                UserProfileJob = model.Job,
                UserProfilePhone = model.Phone,
                GenderId = model.GenderId,
                OrientationId = model.OrientationId,
                StatusId = model.StatusId,
                ReligionId = model.ReligionId,
                UserId = userProfile.UserId,
                Motto = model.Motto,
                StarsignId = starSign.Entity.SignId
            });
        }
示例#18
0
        public UserProfileEntity GetUserProfile(string sUserName, string sPassword)
        {
            UserProfileEntity result             = null;
            IEnumerable <UserProfileEntity> list = null;
            string sqlStatement = "SELECT TOP 1  " + Environment.NewLine +
                                  "Contact.ContactId," + Environment.NewLine +
                                  "Contact.CompanyId," + Environment.NewLine +
                                  "Contact.DepartmentId," + Environment.NewLine +
                                  "Contact.UserAccountId," + Environment.NewLine +
                                  "Contact.Deleted," + Environment.NewLine +
                                  "Contact.Phone," + Environment.NewLine +
                                  "Contact.Address," + Environment.NewLine +
                                  "Contact.FullName," + Environment.NewLine +
                                  "Contact.Email," + Environment.NewLine +
                                  "Contact.Position," + Environment.NewLine +
                                  "UserAccount.UserName," + Environment.NewLine +
                                  "UserAccount.AccountType" + Environment.NewLine +
                                  "FROM UserAccount JOIN Contact ON UserAccount.UserAccountId=Contact.UserAccountId" + Environment.NewLine +
                                  "WHERE UserName=@UserName AND Password=@Password" + Environment.NewLine;

            list   = Connection.Query <UserProfileEntity>(sqlStatement, new { UserName = sUserName, Password = MD5Hash(sPassword) }, Transaction);
            result = list.FirstOrDefault <UserProfileEntity>();
            if (result != null)
            {
                //return original password
                result.Password = sPassword;
            }
            return(result);
        }
示例#19
0
        /// <summary>
        /// 在用户数据库中创建一个新用户。
        /// </summary>
        /// <param name="username">新用户的用户名。</param>
        /// <param name="group">用户具有的权限集。</param>
        /// <returns>新创建的用户的句柄。</returns>
        /// <exception cref="ArgumentNullException"/>
        /// <exception cref="UsernameAlreadyExistsException"/>
        public UserHandle Create(string username, UserGroup group)
        {
            if (username == null)
            {
                throw new ArgumentNullException(nameof(username));
            }
            if (IsUserExist(username))
            {
                throw new UsernameAlreadyExistsException(username);
            }

            // 为新用户分配个人信息文件。
            string            profileFile = GetNewProfileName(username);
            UserProfileEntity entity      = new UserProfileEntity()
            {
                Username        = username,
                ProfileFileName = profileFile,
                UserGroup       = (NativeUserGroup)group,
            };

            // 将实体数据对象添加到数据库中。
            m_context.AddUserProfileEntity(entity);

            return(new UserHandle(username));
        }
示例#20
0
        protected override void Seed(UserDataContext context)
        {
            //  This method will be called after migrating to the latest version.

            //  You can use the DbSet<T>.AddOrUpdate() helper extension method
            //  to avoid creating duplicate seed data. E.g.
            //
            //    context.People.AddOrUpdate(
            //      p => p.FullName,
            //      new Person { FullName = "Andrew Peters" },
            //      new Person { FullName = "Brice Lambson" },
            //      new Person { FullName = "Rowan Miller" }
            //    );
            //

            UserProfileEntity profile = new UserProfileEntity()
            {
                Username        = "******",
                Organization    = "BIT",
                UserGroup       = UserGroup.Administrators,
                ProfileFileName = ApplicationDirectory.GetAppSubDirectory("Users") + "\\Lancern",
            };

            using (SHA512 hash = SHA512.Create())
            {
                profile.PasswordHash = hash.ComputeHash(Encoding.Unicode.GetBytes("Lancern"));
            }

            context.UserProfiles.AddOrUpdate(profile);
        }
示例#21
0
        /// <summary>
        /// Reseta a senha de um usuário
        /// </summary>
        /// <param name="ResetPwdRequest"></param>
        /// <returns>Token de autenticação em caso de sucesso.</returns>
        public static AuthResult ResetPassword(LoginRequest ResetPwdRequest)
        {
            AuthResult authResult = new AuthResult();

            try
            {
                UserAccountEntity user = AccountRepository.Instance.FindByUserName(ResetPwdRequest.UserName != null ? ResetPwdRequest.UserName.ToLower() : null);

                if (user == null)
                {
                    authResult.AuthStatus = AuthStatus.USER_NOT_EXISTS;
                    return(authResult);
                }

                UserProfileEntity profile = AccountRepository.Instance.GetProfileById(user.Id);

                if (profile == null)
                {
                    authResult.AuthStatus = AuthStatus.USER_NOT_EXISTS;
                    return(authResult);
                }

                Random rnd = new Random();

                string newPwd = rnd.Next().ToString(); //"PWD" + rnd.Next();

                NewRequest request = new NewRequest();

                request.Email    = user.UserName;
                request.Username = user.UserName;
                request.Password = newPwd;

                UpdateUser(request);

                string EmailBody = "Olá! sua nova senha para acessar a plataforma do Gamific é: " + newPwd;

                string EmailTo = ParameterCache.Get("RESET_PASSWORD_EMAIL");

                var result = EmailDispatcher.SendEmail(EmailTo, "Nova Senha Gamific", new List <string>()
                {
                    user.UserName
                }, EmailBody);

                if (result)
                {
                    authResult.AuthStatus = AuthStatus.OK;
                }
                else
                {
                    authResult.AuthStatus = AuthStatus.ERROR;
                }
            }
            catch (Exception ex)
            {
                authResult.AuthStatus = AuthStatus.ERROR;
            }

            return(authResult);
        }
        public ActionResult Edit()
        {
            UserProfileEntity user = UserProfileRepository.Instance.GetById(CurrentUserId);

            ViewBag.LogoId = CurrentWorker.LogoId;

            return(View("Edit", user));
        }
 private UserProfile AssignEntityToModel(UserProfileEntity userProfileEntity)
 {
     return(new UserProfile
     {
         UserId = userProfileEntity.UserId,
         UserName = userProfileEntity.UserName
     });
 }
示例#24
0
        /// <summary>
        /// Query user
        /// </summary>
        /// <param name="userHandle">User handle</param>
        /// <param name="appHandle">App handle</param>
        /// <returns>User profile entity</returns>
        public async Task <IUserProfileEntity> QueryUserProfile(string userHandle, string appHandle)
        {
            CTStore store = await this.tableStoreManager.GetStore(ContainerIdentifier.Users);

            ObjectTable       profilesTable     = this.tableStoreManager.GetTable(ContainerIdentifier.Users, TableIdentifier.UserProfilesObject) as ObjectTable;
            UserProfileEntity userProfileEntity = await store.QueryObjectAsync <UserProfileEntity>(profilesTable, userHandle, appHandle);

            return(userProfileEntity);
        }
示例#25
0
        public async Task UpdateUserProfile(IOperation operation, UserProfileEntity entity)
        {
            if (!await userDataStore.IsUserExist(operation, entity.Id))
            {
                throw CommonExceptions.UserWasNotFound(operation, entity.Id);
            }

            await userDataStore.UpdateProfile(operation, entity);
        }
示例#26
0
        /// <summary>
        /// 从给定的 UserProfileEntity 对象创建 UserHandle 对象。
        /// </summary>
        /// <param name="entity">用户信息实体对象。</param>
        /// <returns>UserHandle 对象。</returns>
        /// <exception cref="ArgumentNullException"/>
        internal static UserHandle FromUserProfileEntity(UserProfileEntity entity)
        {
            if (entity == null)
            {
                throw new ArgumentNullException(nameof(entity));
            }

            return(new UserHandle(entity.Username));
        }
示例#27
0
        public UserProfileEntity Create(UserProfileEntity userprofileEntity)
        {
            var query = @"INSERT INTO ""UserProfile""(""Email"",""EmailConfirmed"",""Name"",""Gender"",""Birthdate"",""Phone"",""PasswordHash"",""CreatedDate"",""ModifiedDate"",""ReminderSetting"",""PushNotification"",""AvatarUrl"",""IsDeleted"",""Status"",""Passcode"",""PasscodeExpired"") VALUES(@Email,@EmailConfirmed,@Name,@Gender,@Birthdate,@Phone,@PasswordHash,@CreatedDate,@ModifiedDate,@ReminderSetting,@PushNotification,@AvatarUrl,@IsDeleted,@Status,@Passcode,@PasscodeExpired) RETURNING ""ID"";";

            int id = DbConnection.Query <int>(query, userprofileEntity).Single();

            userprofileEntity.ID = id;
            return(userprofileEntity);
        }
示例#28
0
        public int UpdateProfileDetail(UserProfileEntity Profile)
        {
            UsersProfile Userprofile = null;
            //UsersProfile Userprofile = new UsersProfile();

            int retVal = 0;

            try
            {
                using (var db = new DbContext(CONNECTION_NAME))
                {
                    Userprofile = db.Set <UsersProfile>().Where(s => s.UsrP_UserProfileID == Profile.UsrP_UserProfileID).FirstOrDefault <UsersProfile>();

                    if (Userprofile == null)
                    {
                        return(retVal);
                    }

                    #region Saving ProjectAllocation info Table

                    Userprofile.UsrP_FirstName      = Profile.UsrP_FirstName;
                    Userprofile.UsrP_LastName       = Profile.UsrP_LastName;
                    Userprofile.Usrp_ProfilePicture = Profile.Usrp_ProfilePicture.Replace(" ", "%20");
                    Userprofile.Usrp_DOJ            = Profile.Usrp_DOJ;
                    Userprofile.UsrP_DOB            = Profile.UsrP_DOB;
                    Userprofile.Usrp_MobileNumber   = Profile.Usrp_MobileNumber;
                    Userprofile.UsrP_EmailID        = Profile.UsrP_EmailID;
                    Userprofile.TemporaryAddress    = Profile.TemporaryAddress;
                    Userprofile.PermanentAddress    = Profile.PermanentAddress;
                    Userprofile.UsrP_ActiveStatus   = Profile.UsrP_ActiveStatus;
                    Userprofile.UsrP_Version        = Profile.UsrP_Version;
                    //Userprofile.UsrP_CreatedDate = System.DateTime.Now;
                    //Userprofile.UsrP_CreatedBy = Profile.UsrP_CreatedBy;
                    Userprofile.UsrP_ModifiedDate = System.DateTime.Now;
                    Userprofile.UsrP_ModifiedBy   = Profile.UsrP_ModifiedBy;
                    Userprofile.UsrP_isDeleted    = Profile.UsrP_isDeleted;
                    Userprofile.Marital_Status    = Profile.Marital_Status;
                    Userprofile.Usr_GenderId      = Profile.Usr_GenderId;
                    // Userprofile.Usr_Titleid = Profile.Usr_Titleid;
                    // Userprofile.UsrP_EmployeeID = Profile.UsrP_EmployeeID;
                    // Userprofile.Usrp_PhoneNumber = Profile.Usrp_PhoneNumber;
                    #endregion
                    db.Entry(Userprofile).State = System.Data.Entity.EntityState.Modified;

                    retVal = db.SaveChanges();
                    retVal = 1;
                };
            }

            catch (Exception ex)
            {
                var exc = ex;
                retVal = -1;
            }
            return(retVal);
        }
 /// <summary>
 /// Salva um user profile na base de dados
 /// </summary>
 /// <param name="newEntity"></param>
 /// <returns></returns>
 public UserProfileEntity CreateUserProfile(UserProfileEntity newEntity)
 {
     using (ModelContext context = new ModelContext())
     {
         context.Profiles.Attach(newEntity);
         context.Entry(newEntity).State = System.Data.Entity.EntityState.Added;
         context.SaveChanges();
     }
     return(newEntity);
 }
示例#30
0
        public void AddUser(UserProfile user)
        {
            UserProfileEntity entity = Mapper.Map <UserProfileEntity>(user);

            using (UsersContext db = new UsersContext())
            {
                db.UserProfiles.Add(entity);
                db.SaveChanges();
            }
        }