Example #1
0
        public ResponseModel UpdateUserProfile(UserProfileViewModel profile)
        {
            if (!profile.Valid())
            {
                return new ResponseModel("UserProfileViewModel is not valid");
            }

            if (!_image.ValidatePhoto(profile.Photo))
            {
                return new ResponseModel("Photo is not valid");
            }

            var user = _db.Get<User>(profile.UserID);

            user.Cellphone = string.IsNullOrEmpty(profile.Cellphone) ? null : profile.Cellphone;
            user.Language = string.IsNullOrEmpty(profile.Language) ? null : profile.Language;
            user.Skype = string.IsNullOrEmpty(profile.Skype) ? null : profile.Skype;
            user.Website = string.IsNullOrEmpty(profile.Website) ? null : profile.Website;

            if (!string.IsNullOrEmpty(profile.Photo))
            {
                user.Photo = profile.Photo;
            }

             user.Location = new LocationModel()
             {
                 Country = profile.Country,
                 City = profile.City
             };

            _db.Update(user);

            return new ResponseModel();
        }
Example #2
0
        public UserProfileViewModel GetUser(string userID)
        {
            var user = _db.Get<User>(userID);

            var profile = new UserProfileViewModel();
            profile.Cellphone = user.Cellphone;
            profile.Language = user.Language;
            profile.Skype = user.Skype;
            profile.UserID = user.IDInternal;
            profile.Website = user.Website;
            profile.FirstName = user.FirstName;
            profile.LastName = user.LastName;
            profile.Created = user.created.Value;
            profile.Photo = string.IsNullOrEmpty(user.Photo) ? _image.GetNoPhoto(large: true) : user.Photo;

            if (user.Location != null)
            {
                profile.Country = user.Location.Country;
                profile.City = user.Location.City;
            }

            return profile;
        }