Exemplo n.º 1
0
        public HttpResponseMessage Login(JObject jsonJObject)
        {
            try
            {
                using (var context = new UserDbDataContext())
                {
                    var     entity      = JsonConvert.DeserializeObject <dynamic>(jsonJObject.ToString());
                    dynamic device      = entity.Device;
                    String  email       = DataAccess.UtilFolder.Converts.ToStringFromDynamic(entity, "Email");
                    String  username    = DataAccess.UtilFolder.Converts.ToStringFromDynamic(entity, "UserName");
                    String  password    = DataAccess.UtilFolder.Converts.ToStringFromDynamic(entity, "Password");
                    String  deviceId    = DataAccess.UtilFolder.Converts.ToStringFromDynamic(device, "DeviceId");
                    String  devicetoken = DataAccess.UtilFolder.Converts.ToStringFromDynamic(device, "Token");


                    tbUser user = UserInfo.Login(context, username, email, password, deviceId, devicetoken);

                    return(HTTPResponseHelper.CreateResponse(Request, HttpStatusCode.OK, new { user.FullName, user.Email, user.ImageUrl, user.LastLogin, user.UserName, user.Token }));
                }
            }
            catch (Exception e)
            {
                return(HTTPResponseHelper.CreateResponse(Request, HttpStatusCode.NotFound, new ErrorCls(e.Message)));
            }
        }
Exemplo n.º 2
0
        public HttpResponseMessage GetMemberById(JObject jsonJObject)
        {
            try
            {
                using (var context = new DataAccess.Db.UserDB2.DbDataContext())
                {
                    var     entity    = JsonConvert.DeserializeObject <dynamic>(jsonJObject.ToString());
                    dynamic device    = entity.Device;
                    String  findUser  = DataAccess.UtilFolder.Converts.ToStringFromDynamic(entity, "FindUser");
                    String  requestBy = DataAccess.UtilFolder.Converts.ToStringFromDynamic(entity, "RequestBy");
                    bool    isFriend  = false;
                    DataAccess.Db.UserDB2.tbUser user = UserInfo.getByUserId(context, findUser, requestBy, ref isFriend);

                    return(HTTPResponseHelper.CreateResponse(Request, HttpStatusCode.OK, new { User = new { user.FullName, user.Email, user.ImageUrl, user.LastLogin, user.UserName }, IsFriend = isFriend }));
                }
            }
            catch
            {
            }
            return(HTTPResponseHelper.CreateResponse(Request, HttpStatusCode.NotFound, "Sai tham số"));
        }
Exemplo n.º 3
0
 public HttpResponseMessage Logout(JObject jsonJObject)
 {
     try
     {
         using (var context = new UserDbDataContext())
         {
             var    entity   = JsonConvert.DeserializeObject <dynamic>(jsonJObject.ToString());
             String username = DataAccess.UtilFolder.Converts.ToStringFromDynamic(entity, "UserName");
             String token    = DataAccess.UtilFolder.Converts.ToStringFromDynamic(entity, "Token");
             if (UserInfo.Logout(context, username, token))
             {
                 return(HTTPResponseHelper.CreateResponse(Request, HttpStatusCode.OK, new { Message = "Logout thành công" }));
             }
             return(HTTPResponseHelper.CreateResponse(Request, HttpStatusCode.OK, new { Message = "Logout không thành công" }));
         }
     }
     catch (Exception e)
     {
         return(HTTPResponseHelper.CreateResponse(Request, HttpStatusCode.NotFound, new ErrorCls(e.Message)));
     }
 }