Ejemplo n.º 1
0
        public BaseMessage GetProfile(UserAuthen user)
        {
            if (user == null)
                throw new HttpResponseException(new HttpResponseMessage() { StatusCode = HttpStatusCode.Unauthorized, Content = new StringContent("Please provide the credentials.") });

            var userDb = IoTUserMrg.GetUserCache(user.UserName);
            if (userDb != null)
            {
                //Get data attach (List<int> storesId) - List store by User
                var lst = new List<int>() { 1 };

                Profile p = new Profile();
                p.Stores = lst;

                string profile = p.SerializeJson();
                //Update profile
                IoTUserMrg.UpdateProfile(user.UserName, profile);

                BaseMessage msg = new BaseMessage("","",Framework.Exceptions.ErrorCode.IsSuccess,"");
                msg.SetData(profile);
                return msg;
            }
            else
            {
                throw new HttpResponseException(new HttpResponseMessage() { StatusCode = HttpStatusCode.Unauthorized, Content = new StringContent("Invalid user name or password.") });
            }
        }