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();
        }