public HttpResponseMessage Post([FromBody] UserProfileImplementor[] data)
        {
            return(Execute(delegate
            {
                if (data == null || !data.Any())
                {
                    throw new ArgumentException("No UserProfile change data submitted");
                }

                if (data.Any(d => d == null || d.UserId <= 0 || string.IsNullOrWhiteSpace(d.UserName)))
                {
                    throw new ArgumentException("User data is incomplete");
                }

                if (SessionGlobal.CurrentUser == null || SessionGlobal.CurrentUser.Identity == null || !SessionGlobal.CurrentUser.Identity.IsAuthenticated)
                {
                    throw new Exception("Current user is not authorized to make changes to profile");
                }

                SecurityDb.UpdateUserProfile(data.Select(d =>
                                                         new UserProfileContract()
                {
                    UserProfile = d
                }).ToArray()
                                             , SessionGlobal.CurrentUser.Identity.UserId, false);

                return Request.CreateResponse(HttpStatusCode.Accepted);
            }));
        }
        public void TestUpdateUserProfile()
        {
            var res = SecurityDb.FindUserProfile(null).First();

            res.UserProfile.EmailId = "*****@*****.**";
            SecurityDb.UpdateUserProfile(new UserProfileContract[] { res }, res.UserProfile.UserId, true);
            res = SecurityDb.FindUserProfile(new UserProfileDiscriminator()
            {
                Filter = x => x.UserId == res.UserProfile.UserId
            }).First();
        }