Example #1
0
        public new ActionResult Profile(string id)
        {
            UserProfileInfo user   = null;
            int             userId = -1;

            if (int.TryParse(id, out userId))
            {
                user = this.serviceUser.GetById(userId);
            }
            else
            {
                user = this.serviceUser.GetByLogin(id);
            }
            VMProfile model = mapdata(user);

            return(View(model));
        }
Example #2
0
        public async Task <IHttpActionResult> UpdateProfile(VMProfile profile)
        {
            // Decode the Claims for get all values
            var identity = (ClaimsIdentity)User.Identity;
            IEnumerable <Claim> claims = identity.Claims;
            var idAccount = Convert.ToInt64(claims.Where(c => c.Type == "idAccount").Single().Value);

            profile.Id = idAccount;
            var result = await accountbusiness.UpdateProfile(profile);

            if (result)
            {
                return(Content(HttpStatusCode.OK, result));
            }
            else
            {
                return(Content(HttpStatusCode.InternalServerError, "Error"));
            }
        }
Example #3
0
        private VMProfile mapdata(UserProfileInfo user)
        {//todo use automapper
            VMProfile model = null;

            if (user != null)
            {
                var stats = serviceStatistics.GetStatByUserId(user.Id);
                model = new VMProfile();

                model.Id          = user.Id;
                model.Stats       = stats;
                model.DisplayName = user.DisplayName;
                model.Email       = user.Email;
                model.Login       = user.Login;
                model.PictureUrl  = user.PictureUrl;
                model.CreatedOn   = user.CreatedOn;
            }


            return(model);
        }
Example #4
0
        /// <summary>
        /// add edit user profile
        /// </summary>
        /// <param name="MyProfile"></param>
        /// <returns></returns>
        public long AddEditUserProfile(VMProfile MyProfile)
        {
            UserProfileDomainModel objUserModel = new UserProfileDomainModel();

            /**/
            objUserModel.UserID       = MyProfile.UserID;
            objUserModel.UserName     = MyProfile.UserName;
            objUserModel.Email        = MyProfile.Email;
            objUserModel.PhoneNumber  = MyProfile.PhoneNumber;
            objUserModel.Gender       = MyProfile.Gender;
            objUserModel.HavePassport = MyProfile.HavePassport;
            objUserModel.Married      = MyProfile.Married;
            objUserModel.Description  = MyProfile.Description;
            objUserModel.Status       = MyProfile.Status;
            //user hobby
            if (MyProfile.UserHobby != null && MyProfile.UserHobby.Count > 0)
            {
                objUserModel.UserHobby = MyProfile.UserHobby.Select(obj => new UserHobbiesDomainModel()
                {
                    UserHobbyID = obj.UserHobbyID,
                    UserID      = objUserModel.UserID,
                    HobbyId     = obj.HobbyId,
                    IsDeleted   = obj.UserHobbyID > 0 && obj.IsSelected == false
                }).ToList();
            }
            //user address
            if (MyProfile.UserAddress != null && MyProfile.UserAddress.Count > 0)
            {
                objUserModel.UserAddress = MyProfile.UserAddress.Select(obj => new AddressesDomainModel()
                {
                    AddressID   = obj.AddressID,
                    AddressType = obj.AddressType,
                    UserID      = objUserModel.UserID,
                    Address     = obj.Address,
                    CityID      = obj.CityID,
                    AreaCode    = obj.AreaCode
                }).ToList();
            }
            /**/
            if (objUserModel.UserID > 0)
            {
                IUserProfile.UpdateEntity(objUserModel);
                if (objUserModel.UserAddress != null)
                {
                    var addressToUpdate = objUserModel.UserAddress.Where(x => x.AddressID > 0).ToList();
                    if (addressToUpdate != null && addressToUpdate.Count > 0)
                    {
                        IUserProfile.UpdateListOfEntity <AddressesDomainModel>(addressToUpdate);
                        //foreach (var add in addressToUpdate)
                        //{
                        //    IUserProfile.UpdatedChildEntity<AddressesDomainModel>(add);
                        //}
                    }
                    //var newAddress = objUserModel.UserAddress.Where(x => x.AddressID == 0).ToList();
                    //if (newAddress != null && newAddress.Count > 0)
                    //{
                    //    IUserProfile.AddChildEntityList<AddressesDomainModel>(newAddress);
                    //}
                }
                if (objUserModel.UserHobby != null)
                {
                    var hobbyToUpdate = objUserModel.UserHobby.Where(x => x.UserHobbyID > 0).ToList();
                    if (hobbyToUpdate != null && hobbyToUpdate.Count > 0)
                    {
                        IUserProfile.UpdateListOfEntity <UserHobbiesDomainModel>(hobbyToUpdate);
                    }
                    //IUserProfile.UpdateListOfEntity<UserHobbiesDomainModel>(objUserModel.UserHobby);
                    //IUserProfile.UpdateListOfEntity<AddressesDomainModel>(objUserModel.UserAddress);
                }
            }
            else
            {
                //return IUserProfile.AddEntity(objUserModel);
                IUserProfile.AddEntity(objUserModel);
            }
            IUserProfile.SaveChanges();
            return(objUserModel.UserID);
        }